Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include a JavaScript file in a JavaScript file [duplicate]

Tags:

javascript

Possible Duplicate:
How to include a JavaScript file in another JavaScript file?

I want to include a JavaScript file in a JavaScript file. include('filename.js'); is not working

What is the right code?

like image 986
X10nD Avatar asked Oct 21 '10 20:10

X10nD


1 Answers

function includeJS(incFile)
{
   document.write('<script type="text/javascript" src="'+ incFile+ '"></script>');
}

Then include a second JavaScript file by calling:

includeJS('filename.js');
like image 191
FatherStorm Avatar answered Oct 20 '22 01:10

FatherStorm