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

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -