Created
September 4, 2019 15:53
-
-
Save nolochemical/c173b641ad7a1f2a8945e893eb25dbc1 to your computer and use it in GitHub Desktop.
Quick and dirty JSL add to path with `Async Defer`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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