Skip to content

Instantly share code, notes, and snippets.

@bantic
Created February 3, 2019 15:33
Show Gist options
  • Save bantic/aa28b042e234e80d8b2aa034cae5f471 to your computer and use it in GitHub Desktop.
Save bantic/aa28b042e234e80d8b2aa034cae5f471 to your computer and use it in GitHub Desktop.
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