devxlogo

External JavaScripts

External JavaScripts

Question:
Can a script be placed in an external JavaScript file so it doesn’t have to be placed on all 200 pages of our Web site?

Answer:
Yes, as long as you don’t mind not supporting Netscape 2.x you can reference JavaScript from an external file from your scripts. To do this use the SRC attribute of the SCRIPT tag:

In addition, your Web server must be configured to associate the JavaScript file extension (.js) with the application/x-javascript MIME type.

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