Mobile app version of vmapp.org
Login or Join
Megan663

: I have found that you get the best performance by using a combination. I tend to use: A core combined JavaScript file that contains a concatenation of all the JavaScript that is required

@Megan663

I have found that you get the best performance by using a combination. I tend to use:


A core combined JavaScript file that contains a concatenation of all the JavaScript that is required for every page on the site. In my case this includes jQuery as well as code for lightboxes and menus.

Served as a separate file so that it is cached between page views: <script src="combined-v1234.js"></script>
Versioned by the build system (the 1234) so that users get a new version of it whenever I release newe code to the website. If a browser gets an older version that what is available they get a 301 permanent redirect to the current version. If a browser requests a newer version than what is available they get a 302 temporary redirect to prevent pre-caching.

Code specific to a particular page is included inline conditionally: <script>var contactpage=true;</script>


In both cases I use YUI Compressor to minimize the files as part of the build process so that the web server is serving smaller files.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Megan663

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme