ive been searching for a bit and i cant get a straight answer
you know with php in html you can tell it to include whatever.php thus lowering the HTML size
my question is can i do the same with javascript?
Printable View
ive been searching for a bit and i cant get a straight answer
you know with php in html you can tell it to include whatever.php thus lowering the HTML size
my question is can i do the same with javascript?
Just make use of the 'src' attribute of the script tag.
eg
That would include the script rc.js from the script folder.Code:<script language="javascript" type="text/javascript" src="script/rc.js"></script>
Hope that helps, although im sure you've probably read all this on the w3schools site posted above :)
I don't undertsnad. You mean like C's 'include' preprocessor function?
Kind'a, the difference being that javascript can be included anywhere in the script and there isn't a seperate preprocesser handling it :smile:
I tend to do the same with PHP, write the PHP equivalent of a header file that contains includes to all the files required and call that file once in my index.