devxlogo

Use Script Caching

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:

 

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:

 

devx-admin

Share the Post: