Let’s make the WordPress faster
As many of you already know about 2 years ago Google lunched a project called “Let’s make the web faster”. Today we will talk about the same thing only for WordPress. The popular term “size does matter” is in full swing when it comes to WordPress site speed and to all other non-WordPress sites as well, however in this case we need to size-down quite a bit to achieve best possible performance.
Best (better) practices to increase WordPress site speed
It’s no secret that anything we need there will be a plugin for that right? Well true in most scenarios this is definitely way to go, I for one would almost always recommend a plugin -vs hand coding. There are few available plugins that will increase your site speed and sure you are always free to use any of them.
Speaking from my personal experience only and managing many WordPress sites for my clients on monthly basis I can say that plugins for this are one heck of a tool, but I needed more results and faster page speed. (yes even beyond that)
What I did not want was:
- No static content at any time
- No block to search engine crawlers
To explain. If you are running a business or just a Blog it doesn’t matter, you need things to be fast correct? Meaning that when visitor comes to your site everything needs to open fast and without any hesitations. At the same time you also need the search engine visibility too, not to mention much needed dynamic content that gets updated in real-time. Honestly, years ago I switched to WordPress just because it’s not static. Static pages can also delay crawlers, when crawlers are delayed our information is sent to search engines slower as well.
All right enough of this, show us how
Patients is a virtue my friend, Wait, No! That does not apply here, carry on. Little while ago I switched my hosting provider and I haven’t pushed all I had before, but it will be great start for you. First let me show you something, both image are the latest performance tests, one generate without modifications and another one with (minute difference between two reports).

Old Report

New Report
And this was achieved without any plugins, nothing touched in codes, not even a slight PHP changes and still huge jump in above numbers and overall site performance. As you can see is that YSlow grades this site with 90% and clean A, while Page Speed is at 87% and B. See old report and here is the new report. Sure this can and it will be better once I find more spare time to play with and I will make updates too.
.htaccess time
Simply open your .htaccess and paste this in.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
Header unset Pragma FileETag None Header unset ETag <IfModule mod_headers.c> <FilesMatch "\.(js|css|xml|gz)$"> Header append Vary Accept-Encoding </FilesMatch> </IfModule> <FilesMatch "\.(gif|jpg|jpeg|png|ico)$"> ExpiresActive On ExpiresDefault "access plus 1 month" </FilesMatch> <FilesMatch "\.(css|js|html?|xml|txt)$"> ExpiresActive On ExpiresDefault "access plus 1 week" </FilesMatch> # compress text, html, javascript, css, xml: AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript # Or, compress certain file types by extension: <Files *.html> SetOutputFilter DEFLATE </Files> |
And also http://pastebin.com/7154etKR in case that above does not copy right.
Now the very last I did was minified the css, while keeping my original CSS in style-dev.css for easier management. So that my friends is how we can increase the speed of our WordPress sites. Below you will find more resources and great tools to improve your site performance as well. All you need is GTmetrix for the start and ask me anything you didn’t understand or that needs more explaining.
Resources:
- Let’s make the web faster (articles/tutorials)
- WordPress Optimization/Caching
- GTmetrix
- Using site speed in web search ranking (older article from Webmaster Central Blog)
- Why Marketers Must Care About Site Speed (Search Engine Watch)
Hi Emil,
I had some contact about the keep-alive with my host provider,
They say that its turned of and it stay’s that way.
Here there reason:
——————
On shared hosting, where one server is shared with hundreds of customers, creates ‘keepalive’ only there for that many additional connections are created which reduces the overall performance instead of improving it.
The “advantage” that you would get from keepalive is on our servers, more than offset by the use of high performance SAS drives.
. htaccess by our fully supports keepalive is a setting that is not through. htaccess can be adjusted. The advice on WP forums is not correct.
——————
(used google translator “hope its readable”)
What would you advise me to do?
Thanks & Greet
note: I need a vps (for now website is shared hosting)
Im thinking wat would be better (vps or another profider)
Thank & greet: Raymond
Hi,
Sorry to hear that, usually hosting companies will have this enabled. Try DreamHost for VPS.
Thanks,
Emil
nice guide… htaccess does help a lot but if someone is just looking for a plugin and few steps http://www.psdpakistan.com/webdesigning/wordpress-website-optimization/ this might help too..
Hi Emil,
I incorporated the .htaccess code into my own file and it made a big difference in load time for my website. However when I tested in with GTmetrix, there were a few recommendations such as using efficient CSS selectors for in the Responsive template and removing query strings. I am not sure how to proceed with these changes (I am using a child theme). How do you remove query strings, and what should I do about the CSS selectors? Thanks for your assistance!
Hi Joanna,
Create a functions.php within your Child Theme and add: http://pastebin.com/xqYQtFk1
As far as the selectors, I would not worry too much, however compressing style.css yes.
Emil
Thank you, your post has really improved my PageSpeed and YSlow from C-D to A-B respectively. However, I have 27 external JS files that I want to combine into one file. I was able to combine the 27 javascript files into a SINGLE file: “Combined.js”.
The Problem:
(1) How do I upload and call the combined.js? I have attempted to accomplish this by uploading uploading the “combined.js” to Mysite_Url/wp-content/theme/my_theme/js/combined.js
Next I went to my theme header.php and put this:
(2) After completing step (1) above, I ran Gtmetrix and the new result did not change but IT SHOWS THAT THERE ARE NOW 28 external js files that need to be combined! Previously it was 27 external js files but after adding “combined.js” it is now 28 external files.
Please, have you any idea how to call ONLY the “combined.js” without calling the other 27 separate external js files?
Thanks
Pls note: Site is running WP 3.5
To combine JS, you can use http://headjs.com/ where from you can get all the details as well.
Thanks,
Emil
Many thanks!
no problem
Emil
Hi Emil,
Your tutorial and online support forums are both brilliant – I have learnt a lot using them. I’m looking forward to implementing your suggestions here as my site is performing poorly (page speed 50%, Y Slow 70%). Unfortunately I’ve run into trouble on step 1 – when I make changes to my .htaccess file it returns an internal server error and crashes my site. Do you have any suggestions how I might overcome this?
Many thanks,
Denise
Some servers won’t play nicely, what I can suggest to check each line you have in your .htaccess
just to make sure that something is not missing and also that there are no extras.
Paste one block at the time.
Emil
Thank you
Page Speed from 80% to 88%
YSlow from 70% to 77%
YSlow grade D to B implementing your .htaccess modifications advices and removing query strings in a WordPress Multisite.
GtMetrics is a great tool, so much things that could be optimize!
Thanks