Javascript Script attachment

Comments

1 comment

  • Bilal Al-Shahwany

    Hi, there are multiple options to load js library after page load, you can apply the suggestions below in if statement when treatment is "on":

    1- Using JQuery:

    $.getScript("somescript.js", function(){
       alert("Script loaded and executed.");
     });

    2- Use Javascript:

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

Please sign in to leave a comment.