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: Web
Expertise: Intermediate
Oct 16, 2001

Use Script Caching


Using script caching when a script is extremely large or embedded across multiple pages can improve the performance of code in JavaScript. It also allows you to easily distribute one code for use on many pages.

Include the entire script in a .js file as shown below:
 
<script src="displaydate.js"></script>

This causes the browser to load the script only once, and recall it from cache should the page be reloaded or revisited.

By including the above reference, your browser will now download the code stored inside displaydate.js, and run it as if the code was physically typed onto the page. The library file does not have to be stored in the same directory as the page using it. In fact, you can even reference a library that's on a distant domain! Like this:
 
<script src="http://www.msn.com/displaydate.js">
</script>
Anil Bhimavarapu
 
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