How do I include a JavaScript file in another JavaScript file?
Loading
How do I include a JavaScript file in another JavaScript file?
In a javascript code, you can load another js file as below:
var imported = document.createElement(‘script’);
imported.src = ‘/path/to/imported/script’;
document.head.appendChild(imported);
And in a JQuery, you can load another js file as below:
$.getScript(‘/path of file/script.js’, function()
{
//Your another JS file is loaded now
});