As Brian touched on in his previous post, a site’s performance in terms of the time it takes to load pages can have a significant impact on the site’s conversion rate and user engagement. In this post we’ll cover a few of the most important best practices for improving and maintaining web performance.
Make Fewer Requests
In addition to wisely choosing 3rd parties, you can reduce the number of requests needed to load a page by combining files. Images should be combined into a sprite. The CSS Sprite technique should be used to display the correct portion of the sprite in each location.
Any script that is not essential for initial page load, such as those needed for analytics tracking or user interaction should be loaded asynchronously using an event listener and/or a script DOM element.
Reduce File Size
The amount of data sent on each page request has a significant impact on page speed time, especially when bandwidth is constrained, such as on mobile. Most modern web servers and browsers support gZip compression. Enabling it on the web server is one of the quickest and simplest ways to improve site performance.
Another way to reduce total page size is to reduce the size of the css and js. All unused or duplicate css and js should be removed. Js and css should be minified, which is the process of removing all unnecessary characters from the code such as comments and whitespace (spaces, newlines and tabs).
Leverage Browser Caching
For cacheable assets, such as compiled css or minified js embed a fingerprint such as an md5 hash of the content of the file in the filename. When the file changes so does it’s name. This will allow you to set the Expires HTTP header to the maximum recommendation of RFC guideline of 1 year in the future.
Use a Content Delivery Network
A content Delivery Network (CDN) is a system of web servers distributed across the globe designed to more efficiently deliver content to users from servers closer to them. Serving assets, especially images from a CDN is generally relatively easy and can dramatically improve the speed of a site.
These are just a few of the many best practice techniques that can be employed to provide a fast and enjoyable experience for website users.