-
-
Save bantic/aa28b042e234e80d8b2aa034cae5f471 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function injectJquery(callback) { | |
if (window.jQuery) { | |
return callback(window.jQuery); | |
} | |
let script = document.createElement('script'); | |
script.setAttribute( | |
'src', | |
'//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js' | |
); | |
script.onload = () => callback(window.jQuery); | |
script.onerror = e => alert('The script failed to load: ' + e); | |
document.head.appendChild(script); | |
} | |
injectJquery(function($) { | |
$('h2').remove(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment