dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Web
Expertise: Beginner
Feb 12, 1999

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Use External JavaScript Files

If you have the same JavaScript program appearing on several different Web pages, you might want to consider using an external file. That way all the pages can refer to the same script, and if you want to change it you only need to change it in one place. It also helps keep your HTML files smaller and neater by moving the JavaScript out. External JavaScript files typically use the .js extension.

JavaScript 1.1 and later allows you to use the SRC attribute in the SCRIPT tag:

 
<SCRIPT SRC="../js_files/myScript.js"></SCRIPT>
The file myScript.js doesn't need any script tags, and any page with the above tag can use any of the functions and variables listed in myScript.js.
Steve Renaker
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date