-
-
Save bantic/043bf9d9d09a2eb6c5cc8e456fdb1b5a 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($) { | |
let html = $('body').html(); | |
html = html.replace(/Lorem/g, 'Bacon'); | |
$('body').html(html); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment