warlock.js
function create (path, fn) {
  if (scripts[path]) return fn();

  var el = document.createElement('script');
  var loaded = false;

  // debug: loading "%s", path
  el.onload = el.onreadystatechange = function () {
    if (loaded || scripts[path]) return;
    var rs = el.readyState;
    if (!rs || 'loaded' == rs || 'complete' == rs) {
      // debug: loaded "%s", path
      el.onload = el.onreadystatechange = null;
      loaded = true;
      scripts[path] = true;
      fn();
    }
  };

  el.async = 1;
  el.src = path;

  var head = document.getElementsByTagName('head')[0];
  head.insertBefore(el, head.firstChild);
}
function create (path, fn) {
  if (scripts[path]) return fn();

  var el = document.createElement('script');
  var loaded = false;

  // debug: loading "%s", path
  el.onload = el.onreadystatechange = function () {
    if (loaded || scripts[path]) return;
    var rs = el.readyState;
    if (!rs || 'loaded' == rs || 'complete' == rs) {
      // debug: loaded "%s", path
      el.onload = el.onreadystatechange = null;
      loaded = true;
      scripts[path] = true;
      fn();
    }
  };

  el.async = 1;
  el.src = path;

  var head = document.getElementsByTagName('head')[0];
  head.insertBefore(el, head.firstChild);
}
function create ( path , fn ) { if ( scripts [ path ] ) return fn ( ) ; var el = document . createElement ( 'script' ) ; var loaded = false ; // debug: loading "%s", path el . onload = el . onreadystatechange = function ( ) { if ( loaded || scripts [ path ] ) return ; var rs = el . readyState ; if ( ! rs || 'loaded' == rs || 'complete' == rs ) { // debug: loaded "%s", path el . onload = el . onreadystatechange = null ; loaded = true ; scripts [ path ] = true ; fn ( ) ; } } ; el . async = 1 ; el . src = path ; var head = document . getElementsByTagName ( 'head' ) [ 0 ] ; head . insertBefore ( el , head . firstChild ) ; }
Injects a script. Keeps tracked of injected ones.

@param {String} path
@param {Function} callback
@api private
Injects a script . Keeps tracked of injected ones .