Last active
October 1, 2016 20:00
-
-
Save englishextra/397e62184fde65d7755744fdb7a01829 to your computer and use it in GitHub Desktop.
load JS async
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
/*! | |
* 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