Check if external Javacript file is loaded
Load a Javascript external file if it dosen´t loaded yet.
This function will check if there is a script tag with the external file required. If the tag is allready in de document will skip the document write.
function loadScript(src) { for(var i = 0; i < scripts.length; i ++) { if(scripts[i].src == src) { return; } } var script = document.createElement('script'); script.setAttribute('src', src); document.getElementsByTagName('head')[0].appendChild(script); }
Call this function to insert the script to the document.
loadScript("https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.3/webcomponents-loader.js");