How to load a Javascript file without Script tag? -
i have code have nested <script> tag, inner script tag nothing loads javascript file using src attribute. because, how in code, inner script tag closing outer script.
since inside javascript mode, there way load script without using <script src=""> call?
var js = document.createelement("script"); js.type = "text/javascript"; js.src = "path_to_the_file.js"; document.body.appendchild(js);
but asynchronous, have wait until script loaded use -
var js = document.createelement("script"); js.type = "text/javascript"; js.src = "path_to_the_file.js"; js.onload = function() { //code using script here }; document.body.appendchild(js);
Comments
Post a Comment