Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Last active December 18, 2015 17:49
Show Gist options
  • Save peterwilsoncc/5820756 to your computer and use it in GitHub Desktop.
Save peterwilsoncc/5820756 to your computer and use it in GitHub Desktop.
Async JS loader
PWCC = this.PWCC || {};
console = this.console || {};
console.log = this.console.log || function(){};
console.error = this.console.error || function(){};
(PWCC.exe = function(window, document, $) {
var html = document.documentElement,
body = html.getElementsByTagName('body')[0];
load_async('/path/to/sync.js');
function load_async(script_src) {
var S = 'script',
i=document.createElement(S),
f=document.getElementsByTagName(S)[0];
i.async = i.src = script_src;
f.parentNode.insertBefore(i, f);
}
})(this, document, jQuery);
PWCC = this.PWCC || {};
(PWCC.async = function(window, document, $) {
var html = document.documentElement,
body = html.getElementsByTagName('body')[0];
})(this, document, jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment