Skip to content

Commit

Permalink
Merge pull request #13 from j6s/feature/jquery
Browse files Browse the repository at this point in the history
FEATURE: Load jQuery if not present
  • Loading branch information
dlubitz authored Mar 12, 2020
2 parents 57fe4c2 + 4c844fb commit 90e7532
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Resources/Public/js/cachevisualisation.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
$(document).ready(function () {

function initialize() {
$('div[data-vivomedia-cache-visualisation]').hover(
function() {
var container = $( this );
Expand Down Expand Up @@ -36,4 +35,15 @@ $(document).ready(function () {
}
});
});
})
}

if (window.$) {
$(document).ready(initialize);
} else {
var script = document.createElement('script');
script.src = 'https://code.jquery.com/jquery-3.4.1.min.js';
script.setAttribute('integrity', 'sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=');
script.setAttribute('crossorigin', 'anonymous');
script.addEventListener('load', initialize);
document.head.appendChild(script);
}

0 comments on commit 90e7532

Please sign in to comment.