Best practices for boosting website load times. | |
The load time of a web page is crucial to the success of the site itself. Having a slow or even average load times will cause your site to rank poorly in search engines and when you do finally get a user on your site with a slow site speed its highly likely they won’t stay for long. | |
If your site does have a slow load speed, or your site is currently in development before going live here are the best practices you can follow and implement to create a faster site. | |
Optimize Your Images | |
One of the biggest mistakes developers make is scaling an image in HTML. It might be easier and more convenient but it doesn’t do your site speed any favors. | |
If you have a 700x700px image but want it to appear smaller on your web page avoid doing this: <img width="100" height="100" src="Image.jpg" alt="Image" /> | |
Instead resize the image to the desired height before uploading it to your site removing the need to scale the image in HTML and boosting your site speed. | |
Another way you can optimize your images is to choose the right file type. png’s are typically larger than jpg’s and majority of the time your image will have the correct file format. If there are no translucent areas in the image then it should be a jpg and if it’s not you should convert to the smaller file type. | |
There are a number of plugins you can install that will optimise your images by ‘crushing’ them such as pngcrush. This will further decrease the file size of the image by removing the unnecessary features contained within the image file such as comments. | |
404 Pages | |
404 pages are not only an indicator of a poorly maintained site, a disappointment to users but they are also damaging to your site speed. | |
Every Http request being made will slow your site down, Http request are unavoidable but slowing your site down to load a 404 page is unnecessary and is a useless response. Even if the 404 page is helpful recommending a similar page to the user this will waste even more load time and server resources by querying a database. | |
Duplicate Scripts | |
Including duplicate scripts is a common mistake that many websites even popular ones suffer from especially when a large team is working on a site with multiple members uploading scripts or when having to upload a number scripts. This is damaging to your sites speed as an unnecessary Http request is being made and a JavaScripted execution is being wasted. That’s only from duplicating one script; some sites have multiple scripts duplicated further increasing the damage caused. | |
To avoid duplicating scripts use a script management module. Incorporating this module into your template will also help prevent other script issues from occurring such as adding version numbers to script filenames and dependency checking. | |
The best way to insert scripts is to use the HTML pages script tag or by creating an insert script function in PHP. | |