Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Client Scripting
Expertise: Beginner
Nov 3, 1999

Caching JavaScript Code

Question:
Is it possible to cache a JavaScript or remote .JS file on a client? It seems that while you can cache images, HTML, objects, and so on, caching .JS scripts is not straightforward.

Answer:
Actually, one of the main benefits for putting your code into a separate .JS file as opposed to including directly within your page is that it improves performance. Both Netscape and Internet Explorer will cache your JavaScript code automatically—you don't need to do anything at all to make this happen. In addition, your HTML pages will also become smaller because instead of including all of your JavaScript on every page you can centralize code to one or more .JS files. Finally, this should also make maintaining your code easier since it will all be in .JS files instead of being spread out across all of the pages on your site.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date