Skip to content

Instantly share code, notes, and snippets.

@Kichrum
Created July 22, 2014 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kichrum/1203f58d4ec151b2523e to your computer and use it in GitHub Desktop.
Save Kichrum/1203f58d4ec151b2523e to your computer and use it in GitHub Desktop.
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