Skip to content

Instantly share code, notes, and snippets.

@ryan-blunden
Created October 21, 2012 16:49
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 ryan-blunden/3927560 to your computer and use it in GitHub Desktop.
Save ryan-blunden/3927560 to your computer and use it in GitHub Desktop.
Get Script
function getScript(src, callback) {
var script = document.createElement('script');
script.src = src + '?nc=' + new Date().getTime();
var done = false;
script.onload = script.onreadystatechange = function () {
if (!done && (!this.readyState
|| this.readyState === 'loaded'
|| this.readyState === 'complete')
) {
done = true;
callback();
/* Handle memory leak in IE */
script.onload = script.onreadystatechange = null;
document.head.removeChild(script);
}
};
document.head.appendChild(script);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment