Click to See Complete Forum and Search --> : Placing javascript in its own file


cyberchimp
12-05-2002, 09:12 AM
Site URL: http://www.btinternet.com/~cyberchimp/test/dec/home_test.htm

All the pages on my site include two fairly large chunks of javascript in the HEAD:
(1) a 'slider' (vertical marquee) and
(2) a set of drop down menus (generated using Fireworks)

I would like to place the javascripts in two separate files that could then be called by each page, thereby reducing download time. However, my attempts to deal with the slider in this way have been unsuccessful, and I'm not even sure if this is possible for the drop down menus.

Can anyone help?
Many thanks

AdamGundry
12-05-2002, 02:45 PM
You can link to an external .JS file using the following:

<script type="text/javascript" src="somescript.js"></script>

The browser will parse all the code in order, just as if the contents of somescript.js were between the <script></script>.

Hope this helps

Adam

cyberchimp
12-07-2002, 07:16 AM
Many thanks for this Adam - it works a treat for all the various bits of javascript I have on the pages.
Thanks again

BTW, is there a particular name for these (javascript) files?