Answers for "how to use js code in other files"

2

javascript include js file

function loadScript( url, callback ) {
  var script = document.createElement( "script" )
  	  script.type = "text/javascript";
 	  script.onload = function() {
     	callback()
      };
}
// call the function...
loadScript("js/myscript.js", function() {
  alert('script ready!'); 
});
Posted by: Guest on March-04-2020
2

javascript include a js file from another

// jQuery
$.getScript('/path/to/imported/script.js', function()
{
    // script is now loaded and executed.
    // put your dependent JS here.
});
Posted by: Guest on September-17-2020

Code answers related to "how to use js code in other files"

Code answers related to "Javascript"

Browse Popular Code Answers by Language