src/artoo.helpers.js
function getScript(url, async, cb) {
    if (typeof async === 'function') {
      cb = async;
      async = false;
    }

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

    // Script attributes
    el.type = 'text/javascript';
    el.src = url;

    // Should the script be loaded asynchronously?
    if (async)
      el.async = true;

    // Defining callbacks
    el.onload = el.onreadystatechange = function() {
      if ((!this.readyState ||
            this.readyState == 'loaded' ||
            this.readyState == 'complete')) {
        el.onload = el.onreadystatechange = null;

        // Removing element from head
        artoo.mountNode.removeChild(el);

        if (typeof cb === 'function')
          cb();
      }
    };

    // Appending the script to head
    artoo.mountNode.appendChild(el);
  }
function getScript(url, async, cb) {
    if (typeof async === 'function') {
      cb = async;
      async = false;
    }

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

    // Script attributes
    el.type = 'text/javascript';
    el.src = url;

    // Should the script be loaded asynchronously?
    if (async)
      el.async = true;

    // Defining callbacks
    el.onload = el.onreadystatechange = function() {
      if ((!this.readyState ||
            this.readyState == 'loaded' ||
            this.readyState == 'complete')) {
        el.onload = el.onreadystatechange = null;

        // Removing element from head
        artoo.mountNode.removeChild(el);

        if (typeof cb === 'function')
          cb();
      }
    };

    // Appending the script to head
    artoo.mountNode.appendChild(el);
  }
function getScript ( url , async , cb ) { if ( typeof async === 'function' ) { cb = async ; async = false ; } var el = document . createElement ( 'script' ) ; // Script attributes el . type = 'text/javascript' ; el . src = url ; // Should the script be loaded asynchronously? if ( async ) el . async = true ; // Defining callbacks el . onload = el . onreadystatechange = function ( ) { if ( ( ! this . readyState || this . readyState == 'loaded' || this . readyState == 'complete' ) ) { el . onload = el . onreadystatechange = null ; // Removing element from head artoo . mountNode . removeChild ( el ) ; if ( typeof cb === 'function' ) cb ( ) ; } } ; // Appending the script to head artoo . mountNode . appendChild ( el ) ; }
Loading an external file the same way the browser would load it from page
Loading an external file the same way the browser would load it from page