External JavaScripts

External JavaScripts

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?

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.


Share the Post: