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.

devx-admin

Share the Post: