loadJS.js 672 B

12345678910111213141516171819202122
  1. /*! loadJS: load a JS file asynchronously. [c]2014 @scottjehl, Filament Group, Inc. (Based on http://goo.gl/REQGQ by Paul Irish). Licensed MIT */
  2. (function( w ){
  3. var loadJS = function( src, cb ){
  4. "use strict";
  5. var ref = w.document.getElementsByTagName( "script" )[ 0 ];
  6. var script = w.document.createElement( "script" );
  7. script.src = src;
  8. script.async = true;
  9. ref.parentNode.insertBefore( script, ref );
  10. if (cb && typeof(cb) === "function") {
  11. script.onload = cb;
  12. }
  13. return script;
  14. };
  15. // commonjs
  16. if( typeof module !== "undefined" ){
  17. module.exports = loadJS;
  18. }
  19. else {
  20. w.loadJS = loadJS;
  21. }
  22. }( typeof global !== "undefined" ? global : this ));