Last active
January 11, 2018 22:49
-
-
Save adamculpepper/b1a81efb05a89bf0054521c1e19315fc to your computer and use it in GitHub Desktop.
Injects JavaScript file into a page (not jQuery dependent)
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
// code from Stack Overflow, made into a function | |
// https://stackoverflow.com/a/10735151 | |
function injectJSFile(fileURL) { | |
var script = document.createElement('script'); | |
script.src=fileURL; | |
script.type='text/javascript'; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
} | |
injectJSFile('../assets/js/local-file.js'); // USAGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment