: 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
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.
More posts by @Megan663
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.