Approach 2: Loading JavaScript more quickly
The second approach is to simply spend less time loading the same JavaScript, so that visitors spend less time waiting for the page to render. There are a number of ways to achieve just that:
Techniques used with images, such as caching and parallel download
Free Content Delivery Networks
GZIP compression
Minification
Combining or breaking up JavaScript files
Removing unused code
Techniques used with images
JavaScript files are static files, just like images and CSS files. This means that many techniques that apply to images apply to JavaScript files as well, including the use of cookie-free domains, caching, and boosting parallel loading. You'll find out more about these techniques in Chapter 12,
Free Content Delivery Networks
As shown in chapter 12, serving static files from a Content Delivery Network (CDN) can greatly reduce download times, by serving the files from a server that is close to the visitor. A CDN also saves you bandwidth because the files...