Browse DevX
Sign up for e-mail newsletters from DevX

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



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.



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