Creating script tag using DOM methods

var script = document.createElement("script");
script.type = "text/javascript";
script.src = "file1.js";
document.getElementsByTagName("head")[0].appendChild(script);

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.