How to dynamically insert js.

(function(){
    var externalJS = document.createElement("script");
    externalJS.type = "text/javascript";
    externalJS.async = true;
    externalJS.src = "//www.example.com.js";
    var script0 = document.getElementsByTagName("script")[0];
    script0.parentNode.insertBefore(externalJS, script0);
})();

See reference here.

TOPâ–˛
Post tagged with: js