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:
Expertise: Intermediate
May 6, 1998

Efficiently Sharing Common Client Script Code Across Pages

When you have multiple web pages calling the same client script code, locate the shared script code in a separate file (e.g. Shared1.js) and reference the shared code in each page through the use of the SRC property of the <SCRIPT> tag:
 
<SCRIPT  SRC="Shared1.js"></SCRIPT>
The script file will be downloaded by the first page that references it. Subsequent references will pull the file from the browser cache rather than requiring another download. This is more efficient than other options, such as coding the script in each page or using an ASP include file, which adds the script code to each downloaded page, increasing the page size.

In addition, rather than creating one large common script file, modularize your script files so that script code is not downloaded until it is likely to be referenced by an HTML page.

Jerry Brunning
 
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