View Full Version : External Javascript

05-18-2006, 04:56 AM
I was wondering, when you have a javascript that calls for certain part to be placed in HEAD & other part in BODY can I have this script converted into external file?
This would make it easier for certain editing asa opposed to hunting specific section through out the whole page of code.


05-18-2006, 05:38 AM
You can simply take everything between the <script> and </script> tags and put it into "script.js", refer to that in the opening tag (<script src=....)

And you're done. At least this is the general answer... specifics might be slightly more complex)

The body tag is part of the html and is needed.

All an external .js file is doing is saving you having to have that code at the top of your page... not changing the html.

Just use the body tag like normal, but you can have the .js external and it should be fine.

Make sense? :)

05-18-2006, 07:58 AM
I will give it a shot
thank you very much

05-18-2006, 12:30 PM
Make sure there are no HTML tags, such as <script></script> or <!-- --> in the JS file.

05-18-2006, 07:19 PM
Ah, yeah. Good point there.