Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper function to inject a <script> tag
// Helper function to inject a <script> tag.
function injectScript(url, onload, onerror) {
var script = document.createElement("script");
// onload fires even when script fails loads with an error.
script.onload = onload;
script.onerror = onerror || onload;
script.src = url;
document.head.appendChild(script);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.