-
-
Save allex/423599a745a2af1e585a8f548002478c 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
/** | |
* Simple node.js style script loader for modern browsers | |
**/ | |
function loadScript(src, cb) { | |
var script = document.createElement('script'); | |
script.async = true; | |
script.src = src; | |
script.onerror = function() { | |
cb(new Error("Failed to load" + src)); | |
}; | |
script.onload = function() { | |
cb(); | |
}; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} | |
module.exports = loadScript; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.