function getScript(source, callback) {
  var script = document.createElement('script');
  var prior = document.getElementsByTagName('body')[0];
  script.async = 1;
  prior.insertBefore(script, prior);

  script.onload = script.onreadystatechange = function( _, isAbort ) {
    if(isAbort || !script.readyState || /loaded|complete/.test(script.readyState) ) {
      script.onload = script.onreadystatechange = null;
        script = undefined;

        if(!isAbort) { if(callback) callback(); }
    }
  };

  script.src = source;
}

// Example:
getScript("foo.js", function() { alert("Loaded"); });