Skip to content

Instantly share code, notes, and snippets.

@nolochemical
Created September 4, 2019 15:53
Show Gist options
  • Save nolochemical/c173b641ad7a1f2a8945e893eb25dbc1 to your computer and use it in GitHub Desktop.
Save nolochemical/c173b641ad7a1f2a8945e893eb25dbc1 to your computer and use it in GitHub Desktop.
Quick and dirty JSL add to path with `Async Defer`
(function (id, src, attrs) {
// find in DOM
if (document.getElementById(id)) {
return;
}
//create new node
var js = document.createElement('script');
js.src = src;
js.type = 'text/javascript';
js.id = id;
// add node attrs
for (var name in attrs) { if(attrs.hasOwnProperty(name)) { js.setAttribute(name, attrs[name]); } }
var e = document.getElementsByTagName('script')[0];
e.parentNode.insertBefore(js, e);
//load-n-roll
})('script-loader', 'https://loadme.js', {"data-loader":"jsl-scriptloader","data-attr":3442332,"data-env":"prod"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment