Not only have the load time of the pages improved (a lot), but peoples expectations has gotten higher, if a page takes too long to load people are getting annoyed and bored, and the threshold for pressing the back button and go to the next page in the search results are considerably lower now than before. Studies have shown that most people lose loyalty and interest for your page if it loads slow, and are not likely to come back.
Search Engine Optimization
The visitors are not the only ones that get bored with slow pages, now Google also takes page load times into account when calculating page ranks. And since the goal in SEO is to get to the top of the search results in search engines this is a area we as web developers can’t ignore, although pages speed doesn’t have a huge impact on page ranks as other factors of SEO has it’s worth taking a look at.
Minify Page size
This step is pretty straight forward, go through your HTML or template files, see if there is some way you can simplify your design, remove unnecessary elements, maybe you can do somethings a different way, try utilize CSS to get the same results. Make sure all your CSS is in external files instead of inline mixed with your HTML. Also make sure you properly reset your CSS styles and remove unnecessary styles and that CSS shorthand is used.
Unnecessary whitespace does not add any value to your page other than making it larger in size. The web browser strips it away before rendering the page anyways, so you can lose some weight by removing them for good. How far you want to take this is up to you, by removing the whitespace you also reduce the readability, so if you plan on editing the code later on I would recommend you to only remove as much as you can while still being able to read it, take away double line breaks, If you plan on keeping indentations make sure they are done with tabs instead of spaces (1 tab usually converts to 4 spaces – This would cut the “indentation cost” by 75%) You have to consider how much you can get out of this, and if it’s worth it.
Make sure your images aren’t stored in larger dimensions than you are presenting them to the visitors, it’s a waste to have the visitor download a 1024×768 image if all they see is a thumbnail or sized down version of the image. When you are sure your images aren’t unnecessary large, make sure they are compressed and optimized to decrease the file size. You can use an online tool like Smush.it to remove unnecessary data from the images.
Check that all your static resources are being cached properly, this can be done by placing a .htaccess file inside the folder for your resources that will add and Expires header to all files inside that folder.
ExpiresActive on ExpiresDefault "access plus 1 year"
There are several ways to compress our files before sending them to the client, if you are running apache there is mod_deflate which will compress the files you have specified in the .htaccess file like this:
If you are using PHP you got an even more powerfull compression at your disposal, namely gzip. To enable gzip compression of your output you need to enable output buffering at the beginning of your php files and specify that it will compress using gzip before sending it to the client. Be sure to check if the client accepts gzip, or else it will get garbled data. 😉
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();