devxlogo

Use External JavaScript Files

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:

 

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.

See also  What Are International Payments, And How Do They Work?
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist