SiteForce HomepageWeb Design and Hosting PackagesWeb Design TemplatesWeb Design PortfolioContact SiteForce

Store Your JavaScript Code in a .js File

Posted by Erik M. Cunningham - September 1, 2006

Erik M. Cunningham

In my last post, I told you I was going to show beginners how to store their JavaScript code in a .js file to improve their code to text content ratio. Today, I fulfill my promise.

The first step is to create a new document in Notepad, Dreamweaver or your favorite text editor and save that file with a .js extension (eg. “anyfilename.js”).

Now cut the JavaScript code from the HTML source code of your web page and paste it into your new .js file. Make sure you remove the opening and closing SCRIPT tags from your pasted content.

Finally, add the following code to the HEAD of your HTML document:

<SCRIPT LANGUAGE="javascript" SRC="anyfilename.js"></SCRIPT>

Save your HTML and .js files and publish them to the web. Voila!

1 September 2006 | JavaScript Tutorials, Intermediate JavaScript | Comments

One Response to “Store Your JavaScript Code in a .js File”

  1. 1 Web Design Blog - Web Design & Toast » Blog Archive » Hide your Mailto: Email Address from Spambots with JavaScript 15 September 2006 @ 9:55 am

    […] If you want to be extra tricky, take the code you placed in the HEAD of your document and store it in a .js file to reduce the amount of code in your HTML page and make your email address even more invisible to spambots. […]

Leave a Reply

You must be logged in to post a comment.

Navigation

Archives

Meta

September 2006
S M T W T F S
« Aug   Oct »
 12
3456789
10111213141516
17181920212223
24252627282930


Add to My Yahoo!

Add to Google

Add to Windows Live

Subscribe in NewsGator Online

Add to Netvibes

Subscribe with Bloglines

Add to My MSN

Add to My AOL


Top Web Design Blogs

Blogroll