Is your WordPress site loading slowly? There is a cool tool called Pingdom which creates waterfall charts so you can see exactly what is slowing down your site when it is loading. It’s free and easy to use. After running all of my WordPress sites through Pingdom and doing lots of experiments and research, I’ve come up with these steps to massively speed up your WordPress site.
Before starting, I suggest running Pingdom on your site at least a few times to get a baseline of how long it takes to load.
Here are my top steps to a faster WordPress site:
1. Remove Unused Plugins
Plugins are great. It seems like almost anything you want to do with a WordPress site can be done with a plugin that someone has already written. But, if you don’t realize the downside to plugins, it’s easy to go overboard. The reality is that plugins can be a huge contributor to delay in your site’s load time.
If you don’t believe me, check out a plugin called P3 Performance Profiler (made by GoDaddy, but it’s good, believe me). It generates some cool pie charts showing exactly how much delay each plugin is causing. I was shocked to find out that 87% of the page load time of one of my sites was due to plugins!
If you look at your Pingdom waterfall chart, you’ll also see plugin files as a big culprit. After seeing all of this data, I became a plugin minimalist and deleted any plugins that weren’t absolutely necessary for my site. So go through your site and get rid of any unneeded plugins. Think long and hard to see if you really need each one. Be sure to test thoroughly when you’re done to make sure you haven’t accidentally deleted some feature you need in your site.
Elegant Themes did a study on how some of the most popular plugins affect load time. Surprisingly, Yoast SEO had the worst effect out of those tested!
2 . Clean up Jetpack
Jetpack is pretty controversial because on the one hand, it offers some pretty cool features (like the kickass CSS editor that I love and social network buttons), but on the other hand, it has a lot of bloat in terms of effect on load time. You can see if you click the P3 Performance Profiler pie chart above that Jetpack is the number one contributor to plugin delay in my site (and that is after I’ve deactivated many of Jetpack’s features!)
So, if you’re not using any Jetpack features, uninstall it altogether.
If you are using Jetpack features, you should de-activate individual Jetpack modules! Turn off everything that you’re not using. Unfortunately, many of the “big ticket” items in Jetpack, as far as load time delay is concerned, are things that I need for my site. But, deactivate as much as you can.
The one exception, perhaps, is a Jetpack feature called Photon. Photon is a Content Delivery Network for the photos on your site. It provides a server to deliver these photos to your site while it’s loading, freeing up your server to do other things. While this is pretty cool, I don’t have hard data to show how much it helps. If your site doesn’t have a lot of photos, it might not be worthwhile. Also, since it basically makes a copy of your photos on another server, it can cause strange things when you try to make updates. The documentation says that if you update a photo and keep the same filename name, it won’t be updated in Photon, and your site won’t see it. So, I leave it up to you to decide whether you want to use Photon or not. Personally, I have it off because I don’t want to deal updating a photo a year from now and not having the site update, after I’ve forgotten that Photon could be causing the problem. I could see myself wasting hours trying to figure that one out.
3. Compress Images
A big problem that I see on my clients’ websites is that they don’t compress their images before uploading to WordPress. It is true that WordPress compresses images in many cases, there are cases where this isn’t the case. The user might have chosen to display the full size version, or the theme might as well.
Run Pingdom and look for the big-ticket files that are being loaded, like images, and see if you can reduce the size of those. Make sure images are not bigger than they have to be. Images from digital cameras are often 5000 pixels wide and 2MB to 5MB in size. I usually compress them to be 1200 pixels wide with 80% quality, bringing them down to 200kB or less, a huge difference!
4. Clean Up Your Database
Among other things, P3 Performance Profiler tells you how many database calls your site makes. In my case, it was a whopping 60 database calls! I bet that’s not so unusual and may be on the low side.
I use a plugin called WP-Optimize to clean up my database. WP-Optimize won’t reduce the number of database calls, but it should make them snappier.
WordPress stores a full version of your post or page every time you hit the “Save” button. That can mean you have hundreds of drafts of any one article saved in the database. WP-Optimize will clean these off. It will also get rid of spam comments.
I just ran this on a few of my sites and it reduced the size of my database by 30-50%. If you haven’t ever cleaned up your database before, the savings might be even greater for you.
But, unlike the first three items on this list, I don’t have hard data to show faster load time after using this plugin. It’s just too hard to measure. I can’t prove it with data, but it makes sense intuitively that a smaller, cleaner database would be faster. On the other hand, cleaning up the database probably provides the smallest speed improvement on this list, unless your database is really bloated.
Indeed, the plugin itself inherently causes some delay, but its contribution to load time is miniscule according to P3 Performance Profiler. In the end, I believe the benefits are worth it, and you could always deactivate it after cleaning your database if you want. At the very least, WP-Optimize will free up wasted database disk space and make your backups run quicker, which has some benefit.
5. Use a Caching Plugin
When done properly, caching can massively speed up your site, perhaps by a factor of two to ten times, on a slow site. However, when done improperly it can massively slow down your site and cause a whole host of other problems including outright breaking your WordPress site. Use carefully.
What is caching? In the previous step, I said there were 60 database calls in one of my home pages. Caching will drastically reduce the number of database calls by storing your site as static HTML. The speed improvement from doing this can be insane.
WP Fastest Cache
My new favorite caching plugin is WP Fastest Cache. It’s simple to set up and gives great results.
A few caveats though. Caching, by its very nature, has some bad side-effects, namely, dynamic content might not update. I noticed that my Jetpack sidebar widget showing most popular articles never updated because it was cached. Commenting within the Jetpack gallery also didn’t work while caching was enabled. Make sure to test your site thoroughly if you enable WP Fastest Cache.
WP Super Cache
The first caching plugin I tried was WP Super Cache, since it has great reviews. At first, I was in awe at the speedup. After testing for a day or so, I noticed that sometimes my site would take a long time to load (ten to twenty seconds) or not load at all (freeze at white screen in browser). I am sure if there was some setting I had wrong, but at that point I lost patience and uninstalled it. I was probably hasty, as WP Super Cache does have good reviews, as I’ve said. On the other hand, there are also lots of people who reported that it slowed down or caused their sites to hang. I was one of them.
W3 Total Cache
After removing WP Super Cache, I installed W3 Total Cache (which also has great reviews) and naively enabled all speedup options. This massively slowed down my site as well. After a lot of experimentation and testing, I found that in my case it was best to enable just one of the functions: “Page Caching (Disk: Enhanced)”. Object caching and database caching caused my sites to slow down.
It turns out that many of the more advanced features require a lot of server expertise to set up, and may not be effective on shared hosting. Thus, I was stuck with the bare-bones page caching feature.
But even then, the speedup was immediately apparent. All I can say is “wow”. I’d say it sped up the load time of my sites by a factor of at least two or more. If you look at the chart below, you’ll see a noticeable improvement in average load time compared to when caching was off. There are still peaks of slow load time (probably due to my cheap hosting), but the average page load time is faster and the best page load times are massively faster. The proof is in the pudding.
But, this is literally after DAYS of testing the various options on it. Save yourself some headaches and just enable page caching, at least to start with, and proceed with caution after that if you’re greedy for more speed.
One note, if you run P3 Performance Profiler with W3 Total Cache, you’ll notice that the number of database calls reported doesn’t go down. I believe that’s because P3 Profiler turns caching off when doing its scans.
The Dangers of Caching
There is an insidious problem with caching that you need to be aware of. Since caching involves making a copy of your pages, there could be some strange behavior when you make updates and things don’t update for the user. Theoretically, the caching plugin should clear the cache and make a new “copy” of your page whenever you make an update, but I when I update content without clearing the cache, the changes don’t show up in iOS. I know iOS has some “interesting” caching behavior of it’s own that might have complicated things. Clearing the cache manually just takes a button press, so it’s not a big deal once you know what’s going on. If you don’t, you could be pulling your hair out wondering why the site is not updating. While these caching plugins are almost perfect, it’s just something to be aware of. I would be very wary of enabling caching for a client’s site if they were not tech-savvy.
There are also some plugins that are not compatible with caching. For example, Jetpack’s email form won’t work with W3 Total Cache. You can get around this by disabling caching for that page.
6. Use a Content Delivery Network
Using a Content Delivery Network (CDN) means that your images will be loaded from a different server than the rest of your site, relieving your server of a lot of work (and delay). This can be helpful in sites with lots of images.
Jetpack has a built-in CDN called “Photon”. Simply activate it. Your results will vary depending on the number and size of images on your site. In my real-world testing, I’ve gotten load time improvements of up to a second! However, you’d probably have to take a larger sample size over a longer period of time to get more accurate results.
There are some caveats. By introducing another server, you’re adding another potential source of unreliability. If that server goes down, your images won’t load. I’ve seen this happen on rare occasions.
Also, remember to deactivate the feature if you’re changing images on your site. With it activated, the changes might not show up on the live site.
7. Remove Query Strings from your CSS and JS Files
Query strings are snippets of text added to the end of file names starting with a question mark. Here is an example:
These can prevent proxy caching servers from caching these files, resulting in unnecessary re-loads. Removing them can speed up your site after it is viewed for the first time.
Check your site’s HTML code to see if you have these query strings. If so, your site might benefit from removing them.
Happily, there is a simple plugin that does this for you, Remove Query Strings from Static Resources. In my testing, simply installing and activating this plugin resulted in a 2-3 point increase in the site’s Pingdom performance grade (hey, every little bit helps).
A couple of caveats though. You should thoroughly test your site after installing this, as it can break certain types of code. Also, you should deactivate this plugin during development, because if you make changes to any CSS or JS files, they won’t get updated when you re-load the site.
8. Update PHP
Updating PHP on your server from 5.x to 7.x might be one of the easiest ways to get some load time improvement for your site!
If you have shared hosting, check your hosting control panel for “PHP”. There is usually an option to upgrade there by simply checking a radio button. Just test your sites thoroughly afterwards!
9. Eliminate Redirects
You might be thinking, “my site doesn’t have any redirects”. That’s what I thought, until I looked at my Pingdom waterfall chart:
It turns out that the “www” at the beginning of my URL combined wtih forcing SSL were causing TWO redirects, costing about 0.67s of load time right at the outset!
In this case, I was using a plugin to redirect from http to https. It’s faster to do this in your .htaccess file (if you’re on Apache).
10. Combine and Minify Files
Also, look for broken file references (code referencing files that are not there) and clean those up.
11. Change Hosts
Often the problem is simply that your server is too slow. If you have cheap shared hosting, then your server’s CPU might be busy when someone visits your page. It might not even start loading your page for several seconds (look at the first bar of the Pingdom waterfall chart), basically nullifying all of the efforts you’ve made, because it doesn’t matter how lean your site is if it hasn’t even started loading yet!
All of my personal sites and blogs (including this one) are hosted on SiteGround. I highly recommend them for affordable shared hosting. Their servers are blazingly fast and they offer powerful caching.
I recently switched a client from Bluehost to WP Engine, and the speedup was insane. Sites loaded in a few seconds instead of ten seconds or more!!! But, they are more expensive.
In my experience, Inmotion also offers fast servers (relative to other shared hosting providers).
12. Use a Faster MySQL Server
MySQL database calls can be a big culprit when it comes to slowing down your site. I’ve seen this first-hand: my static HTML sites (with no database) are often lightening-fast when my WordPress MySQL-based sites on the same server are massively dragging. The big difference is that my static sites have no database calls.
If you don’t want to deal with caching, and you don’t want to deal with the setup headaches of a VPS, then one compromise that could have big bang for the buck is to get a faster MySQL server. A friend of mine who has Media Temple (I believe that was what he had) told me that they offer an faster MySQL option for just a little more per month, and that massively sped up his site. Unfortunately, not all hosting companies provide this option. If your hosting company doesn’t, then something to look into is Amazon Relational Database Service (RDS). Basically, Amazon can give you cloud-based MySQL hosting. I have not personally tried this, but it seems encouraging.
13. BONUS: Convert Your Site to a Static Site
There is one thing that you can do which will probably make a bigger improvement to your WordPress site’s load time than anything else on this list: converting it to a static site. In my experiment, I converted a WordPress blog to a static site using the Simply Static plugin and load time went from six seconds on average to under one second. This type of performance increase is pretty insane, especially when you consider that the site is on cheap shared hosting.
So why not do it all of the time? Well, there is a pretty big tradeoff, namely, that you can’t have any server-side dynamic content on the site. This includes server submit forms, server-side commenting, server-side e-commerce functionality, events management, membership, and on…
BUT, this does work for purely informational websites like company online brochures or blogs. For commenting, you can use client-side solutions like Disqus.
So, this solution is not for every website by any means (that’s why I have it as a “bonus” tip), but if your site is purely informational, you might want to consider it. If you do it, your site will get also get massively improved reliability and security as a bonus.
Hope this has helped. Let me know your ideas for speeding up WordPress! – Brian