Skip to content

Instantly share code, notes, and snippets.

@1337
Last active October 4, 2015 13:48
Show Gist options
  • Select an option

  • Save 1337/2648231 to your computer and use it in GitHub Desktop.

Select an option

Save 1337/2648231 to your computer and use it in GitHub Desktop.
get any one script
var getAnyOneScript = function (scripts) {
// TODO: http://stackoverflow.com/questions/2027849/how-to-trigger-script-onerror-in-internet-explorer/2032014#2032014
scripts = scripts instanceof Array ? scripts : [scripts];
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', scripts[0]);
script.onerror = function () {
scripts.shift();
getAnyOneScript(scripts);
};
document.body.appendChild(script);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment