Skip to content

Instantly share code, notes, and snippets.

@englishextra
Last active October 1, 2016 20:00
Show Gist options
  • Save englishextra/397e62184fde65d7755744fdb7a01829 to your computer and use it in GitHub Desktop.
Save englishextra/397e62184fde65d7755744fdb7a01829 to your computer and use it in GitHub Desktop.
load JS async
/*!
* load JS async
* modified order of arguments, removed CommonJS stuff
* github.com/filamentgroup/loadJS
* gist.github.com/englishextra/397e62184fde65d7755744fdb7a01829
* @param {String} _src path string
* @param {Object} callback callback function
* loadJS(_src,callback)
*/
var loadJS=function(_src,callback){"use strict";var ref=document.getElementsByTagName("script")[0];var script=document.createElement("script");script.src=_src;script.async=true;ref.parentNode.insertBefore(script,ref);if(callback&&"function"===typeof callback){script.onload=callback;}return script;};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment