WordPress Speed Optimization Guide – Part 2
In the first part of our WordPress Speed Optimization Guide, I have already explained the entire procedure to take the site backup before beginning the speed optimization of any WP site. I have covered separate sections about conventional WP backup system as well as WP Engine backup. Controlling comment spam, Updating WordPress core installation, WP Plugins and cleaning junk files are some of the other topic covered in WP site speed optimization guide Part 1. It is highly recommended to go through Part 1 of this guide before moving any further to get a better understanding about the entire WP site speed optimization procedure.
Continuing our series of WP speed optimization tutorial, let us move ahead with the next steps towards speeding up WordPress sites.
6Tweak wp-config.php file to Improve Site Load Speed
A very important file in WP install is wp-config.php. The file is also quite instrumental behind configuring WordPress install to achieve better performance. Before making any changes to wp-config.php, download a copy of the file to your local PC so that the file can be uploaded back to restore the site in case of anything going wrong breaking your site down. Edit wp-config.php by adding the following code at the bottom of the file.
define('WP_POST_REVISIONS', 12); define('WP_DEBUG', false); define('WP_MEMORY_LIMIT', '98M'); define('WP_MAX_MEMORY_LIMIT', '128M'); /* That's all, stop editing! Happy blogging. */
7Tweak .htaccess file to Improve Site Load Speed
Quite similar to wp-config.php, another important file in WP install is .htaccess file. Configuring .htaccess file in the right way holds the promise to load WP sites faster. Before editing .htaccess file, download a copy of the file to your local PC. It will help you restore the site in case of any abnormal behaviour observed after editing the original file. Edit .htaccess file by adding the following lines of code at the beginning of the file.
8WP Site Speed Optimization with Site Speed Analytic
Site speed analytic offers some effective site speed optimization tools to understand the site speed behavior. Looking at various site speed analytic reports, you can diagnose the site speed issues hitting your site. Once the site speed problems are successfully diagnosed, you can improve site load speed by resolving all the diagnosed site speed problems one by one. For baseline WP site speed analytic reports, I prefer some online site speed testing tools.
In order to get the best site speed analytic reports, try to use the location for all the tests as Dulles, Virginia in United States of America.
Page load time is directly proportional to the page size. Larger is the page size, higher is the page load time and slower is the site load speed. My rule of thumb is to have a maximum page load time of 1 second for a page size 1 MB. For example, If the page size is 2 MB then the page should load in not more than 2 seconds. As an example, I have considered my own website as a study object to explain the entire WordPress speed optimization process.
Let us have a look at the Pingdom Tools site speed test report of my own website.
Tested from Dallas, Texas, USA on August 1 at 13:01:20
Page size: 424.4 kB
Load time: 437 ms
Perf. Grade: 100/100
Your website is faster than 98% of all tested websites
Now, look at the Performance Grade TAB on the speed test report to see that I have already fixed almost all the page speed factors because of which speed test results are awesome.
While checking your site speed on Pingdom tools, you may find these factors showing values below 100%. All the page speed factors scaled below 100% should be fixed to improve your WP site speed.
You should check your own WordPress site to analyse the various speed factors which are in need of improvement. Now, I am going to explain some of the most important areas related to speed issues as faced by majority of WordPress sites. Moreover, in this speed optimization guide, I am also going to help you get rid of all such speed related blockages pulling your site down on speed meters.
8.1How to Fix Remove Query Strings from Static Resources ?
One of the major speed pulling factor is the presence of query strings on static resources. Most of the caching systems will not cache any resource containing a “?” in the URL, even if a Cache-control: public header is present in the response. It means that the URLs must be free from “?” to allow caching systems cache all such resources.
Remove Query Strings from Static Resources is an easy to use simple WordPress plugin that does the job of removing query strings from static resources quite efficiently. You can even download the plugin directly from atulhost.com. Install the plugin, activate it and you are done with this site speed factor.
8.2How to Fix Minify Resources for Improving Site Load Speed ?
After minifying the resources, it also uses optimal client-side cache headers and gzip encoding to reduce the load on server, thus improving page load time. The WP plugin is easy to install. It can also be easily activated on your WordPress install.
From WP Dashboard, Add New Plugin WP Minify Fix.
Activate the plugin.
After activating Remove query strings from static resources and WP Minify WP plugins, scale your site speed on Pingdom Tools to observe the difference. A comparative analysis of your site speed test results before the activation and after the activation of these WordPress plugins will help you analyse the site speed performance achieved so far.
Now, let us have a look at GTmetrix site speed test report to fix some other site speed factors for increasing site load speed.
Page Speed Grade: (94%) A
YSlow Grade: (92%) A
Page load time: 0.90 s
Total page size: 401 KB
Total number of requests: 45
Study the test report, understand, analyse and try to observe the effect of different site speed factors (listed as Recommendations under Breakdown) on page load time. By clicking the various speed factor tabs, you can watch the detailed speed optimization analysis to proceed further, along with reading the recommendations for fixing these site speed issues.
Download the files and replace the original files on your WP install with these downloaded files, but do not forget to backup your files before substituting. If you notice any abnormal behavior after replacing the files, restore the original file back.
An ideal situation would be to push all the site speed factors to 100%, but because of many external dependencies, it would not not be practically feasible. Although, we can improve most of the site speed factors to a score of 100 or quite close to 100. Let us fix these speed hindrance factors one by one.
8.3How to Serve Scaled Images for Improving Site Load Time ?
Serving scaled images means uploading the same image size as framed to display in the web page. As an example, if you have uploaded an image of size 400px × 400px against an image displayed on the web in size of 200px × 200px then you are not serving scaled images. In such a case, WordPress has to resize the image from its uploaded size to the served size, thus adding to the page load overhead.
It is highly recommended to upload the same image size as it is served to display on the web page. Scale your images to the exact served size before uploading it. Once, you scale all the images to the correct size, the GTmetrix speed test report will shown a score of 100 against Serve Scaled Images. Use a photo editor as per your convenience to scale images.
8.4How to Optimize Images to Reduce Page Load Time ?
Click on the Optimize Images Bar to see the status of unoptimized images on your site after making the site speed test. You will see a list of images along with its full path. Moreover, you will also see a link to an optimized version of the image next to the original image link. GTmetrix has already optimized the non-optimized images and has placed a link.
It will also show some statistics about the compression and the file size savings after optimization. An easy way to optimize your site images would be to download these optimized images to your local PC, rename the files and replace it with the non-optimized files existing in your WP install. You can use cPanel or any FTP client to upload files from your local PC to WP install.
As an alternative, you can also use some image optimization tools to optimize images with an objective to reduce page load time.
You can use employ any of the above online image optimization tools to optimize images before uploading it to your WP install.
8.5Minimize Calls to Other Sites from Home Page to Improve Site Speed
Keep your home page free from external site links or at least minimize it to reduce page load time. Lesser is the number of calls to other sites from your home page, better is the site load time. In order to understand this concept, let us have a look at the following webpagetest speed test report.
First Byte Time : A
Keep-alive Enabled : A
Compress Transfer : A
Compress Images : A
Progressive JPEGs : A
Cache static content : B
Effective use of CDN : YES
First View – 1.560 s
Repeat View – 0.942 s
First View is one of the most important speed analytic factors as this is the site load time for a first time user. Ideally, it should be below 3 seconds.
Repeat View is the page load time for a repeat load by a user who comes back to your site. If the site has deployed the right caching methods, the value of repeat view will always be less than the First View.
The above WP site speed analytic report is not disclosing much about the overhead because of loading external site’s objects, but if you look at the domains tab of the same speed analytic report, you will find some detailed information about the impact of external links on your site.
As an analogy, you can compare it with a scenario where you drive to the market for purchasing bread. When you get back home, you realize that you forgot to buy the milk. Now, you drive back all the way to market once again to purchase the milk.
Creating an external link on your home page does the same. Let us say, you have a Twitter widget or Facebook widget on your home page. Now, your web host server has to load the items from Twitter before loading your website. It increases your site’s page load time by adding to page load overhead.
I highly recommend to keep home page neat and clean. Ideally, it must be free from calling external site’s objects or at least minimize it to the best possible extent. Keeping your home page free from calling other sites will speed up site load as server will have to handle less calls for loading your WP site.
Apart from the above mentioned site speed testing tools, you can also use the following online speed analytic tools for some detailed site speed analysis.
You can now proceed to WP Speed Optimization Guide – Part 3 for the rest of the steps.
You may also like to have a look at some of the my other related posts such as impact of WP Plugins on site load speed, impact of web host servers on site speed and how bad is CPU Throttling for website load speed.
Post Editor : Ashutosh Kasera