Found JS injection code from Facebook that can be tuned by a developper.
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)){ return; }
js = d.createElement(s); js.id = id;
js.onload = function(){
// remote script has loaded
};
js.src = "${scriptURI}";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', '${ScriptID}'));
-Greg
Hey,
I am looking for a way to better organize the scripts in our templates. Is the option with the variable and injection still considered best practise? If so, can someone help me come up with a robust injection script? I'm afraid I am too inexperienced to convert the Facebook sample into something suitable and don't want to mess up, the solutions I found on Google seem to be more or less shady 🙂