Created
July 22, 2014 07:41
-
-
Save Kichrum/1203f58d4ec151b2523e to your computer and use it in GitHub Desktop.
Helper function to inject a <script> tag
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
// 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