/    Sign up×
Community /Pin to ProfileBookmark

Placing javascript in its own file

Site URL: [url]http://www.btinternet.com/~cyberchimp/test/dec/home_test.htm[/url]

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

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryDec 05.2002 — 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
Copy linkTweet thisAlerts:
@cyberchimpauthorDec 07.2002 — 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?
×

Success!

Help @cyberchimp spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...