Created
January 9, 2012 05:22
-
-
Save josephj/1581285 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
/** | |
* The utility function to append JavaScript for script tag hack. | |
* | |
* @method _appendScript | |
* @param url {String} The JavaScript URL. | |
* @param loadHandler {Event} The onload event handler (optional). | |
* @return {HTMLElement} The script element. | |
*/ | |
_appendScript = function (url, loadHandler) { | |
loadHandler = loadHandler || null; | |
var scriptEl = document.createElement("script"); | |
scriptEl.src = url; | |
scriptEl.async = true; | |
document.body.appendChild(scriptEl); | |
if (loadHandler) { | |
scriptEl.onload = loadHandler; | |
} | |
return scriptEl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment