Here are some tips on how to fix a slow WordPress site. These are just a few of the items we go through when we do performance optimization work as part of our managed wordpress hosting.
Tip 1: Remove Slow Plugins
If you have a slow WordPress site, you can blame a plugin.
Without plugins, WordPress is fast — but without plugins, WordPress is pretty simple. So you probably need a few plugins just to get the features you need.
Unfortunately, plugins (and themes) can cause your site to slow down. For every plugin you have in your site, there’s more code, more database queries and more work for your server to do. Plugins often do not get work well together due to programming conflicts.
To fix this, you have to find the problematic plugin and remove it. Often you can find another plugin that will work better — or preferably find a way to ditch the plugin completely.
3 Methods to find Slow WordPress Plugins
- Divided & Conquer
- P3 – Plugin Performance Profiler
Divide & Conquer
This method is simple but works – especially if you’re not the one that developed the site.
1) Disable all plugins and measure site speed.
2) Enable ½ of the plugins and measure site speed.
- If the site is slow, disable half of the enabled plugins.
- If the site is still fast, enable half of the remaining plugins
Continue using this type of split until you find the plugin or group of plugins causing the problem. Not the most complex of methods, but it works and is easy to do.
P3 – Plugin Performance Profile
P3 – Plugin Performance Profiler will help you identify problematic plugins.
Simply install P3 and run a scan.
Once you have the results, go to the detailed breakdown page and see which plugins are causing the most problems. On our site, the theme itself is the biggest problem. So not many plugins to disable.
In this case, we don’t have a performance issues, but if you do, you will easily see which plugins are causing the problems.
I don’t get too bogged down into the numbers. You are looking for obvious problems with this tool. For more advanced WordPress performance optimizations, you need a tool like NewRelic.
In short, NewRelic provides PHP application performance profiling. What this means is that you can often pinpoint down to a specific function or MySQL query what is causing the performance issues. See the Measure First bonus tip for more details on New Relic.
Tip 2: Ditch Plugins
You can often avoid plugins and the performance problems they create by using some code. Why some developers pack WordPress with 20-30+ plugins, I will never know. Too often, I see professionally developed sites bloated with plugins for simple features better handled by code.
I often see plugins for these features:
- Website stats
- Social media integration
- Profile Tools
- Font Tools
You can get the same results of many of these plugins by using a piece of code. For example, GoogleAnaytics for WordPress has over 5 million downloads. Don’t get me wrong — it is very well written, but you can achieve similar results by just putting your code in your site’s header.
ManageWP has a list of 10 code snippets you can use to do away with a number of plugins. They use the Code Snippets plugin to do away with several plugins. If you can add one plugin and remove 10, I’m for it.
Tip 3: Caching
If your WordPress site is still slow after ditching the plugins, you may want to turn to caching. Caching can occur at different levels:
- Database Caching
- PHP OpCode Caching
- Browser Caching
Never assume that the server you lease is optimized for database operations. In fact, most server providers make no MySQL optimizations on newly deployed systems. You need to optimize MySQL.
Digging into MYSQL optimization is an entire book, so I just want to highlight a couple of key items to adjust on your server
These are the two items that need to be tuned. There are plenty of other settings, but these are key. If in doubt, ask your host for advice or hire someone to do some server-side performance optimization.
Also be wary of “recommended” MySQL settings for WordPress. While the core software may be the same, you probably have different plugins, theme, post count and traffic patterns. I suggest instead starting from the my-huge.cnf, my-medium.cnf or similar examples and adjusting as needed from there.
Depending on your hosting environment, you may have access to what is called OpCode Caching. Opcode tools cache compiled PHP code in memory – allowing for faster execution.
There are 3 major PHP OpCode cache systems:
I recommend using APC. APC is well supported over a variety of environments.
Probably the most overlooked performance boost is browser caching. Browser caching tells your web site visitor’s browser what data may be cached for future use. This can significantly speed up a site.
Look at how www.rackaid.com performs on initial and repeat loads. Most of the site is cached, so following page views are remarkably fast. On the first view, the total load time is 4.5 seconds and start render is at 2.682s. On the repeat view these number improve because the browser caches files locally. In this case, the repeat view required only 2 HTTP requests.
Browser caching is controlled by cache and expires headers. We have some tips on how to add expires headers in our blog series on how to speed up your site using YSlow.
Tip 4: Full Page Caching
Want a magic bullet? Try a plugin that creates a full page cache of your WordPress blog. There are two performance related plugins that I find work well in fixing slow WordPress sites:
These tools essentially create a static version of your web site. For sites where content does not change frequently, then can save tons of PHP and MySQL processing. A cached page can be served 20-30X faster than a non-cached page.
For example, WP Super Cache will put this in your HTML so you know how fast things are happening:
<!-- Dynamic page generated in 0.566 seconds. --> <!-- Cached page generated by WP-Super-Cache on 2014-02-18 16:54:08 -->
This tells you that the page was generated in 0.566 seconds — quite fast. But serving this page from a static file eliminates this half of second.
With any plugin, these tools do have their problems. If you have a highly dynamic site, you may find that comments are delayed or scheduled posts do not execute exactly when you want.
This is one of the trade-offs when using aggressive cache methods. You give up some of the real-time nature of WordPress for the performance of static HTML code.
Like database tuning, which WordPress performance plugin will work for you depends on your site.
In my experience, WP Super Cache causes fewer issues on complex sites while W3 Total Cache provides more optimization techniques.
Tip 5: CDNs & Accelerators
Content delivery networks (CDNs) and Web Performance Optimization (WPO) services can speed up your slow WordPress site.
CDNs work by offloading your static content (images, css, js) to a distribution network. The result is that your server no longer handles these requests.
If you examine a modern web site, the HTML or PHP page is just one request out of dozens. By offloading these requests, you unleash your server from these tasks. CDNs provide a globally distributed network which has other performance benefits.
Web Performance Optimization (WPO) services go beyond simple CDN optimizations. These services provide caching, image optimization, CSS minimization and other techniques to boost performance.
I’ve used the WPO provider CloudFlare with excellent results for some customers.
CDNs and Cloudflare primarily benefit highly trafficked sites. If you have traffic spikes or just cannot fix the issues using the tips above, you may want to look into a WPO service provider like CloudFlare.
Bonus Tip: Measure First
So why is this last if you should do it first?
Simple – people like to jump in and start trying to fix things, so I put the fixes first but you really should start by benchmarking.
Too often WP developers start making changes to servers and sites before they even known what’s causing the bottleneck. If you don’t profile your site, pinpointing why your WordPress blog is slow is difficult.
There are several tools you can use to profile your WordPress Site.
By profiling your site, you can understand why your WordPress is slow.
Some tools to try:
WebPagetest is an open source project that is largely being developed and supported by Google as part of our efforts to make the web faster.
Their description pretty much sums it up. I don’t want to go into all of the metrics, but if you are serious about improving your sites performance, you want to benchmark it. Run several tests to rule out variations. I usually do 10 tests to produce an average score. Check them out at WebPageTest.org.
Focus on the waterfall charts and not the letter grades. The letter grades can be highly misleading, so pay attention to the details.
I’ve already mentioned this tool. If you are serious about performance, this tool is excellent. NewRelic provides detailed PHP and MySQL profiling. The only drawback is you have to install it on your server first. I usually use it in conjunction with WebPageTest for advanced performance optimization.
Sometimes WordPress performance issues do not manifest until you have high levels of traffic. To simulate traffic you can use a tool like Blitz.io They provide an easy approach to stress test your sites. I usually use this interactively with the tools above – make changes, stress test, review results and repeat.
Using tools like these can make speeding up a slow WordPress site easier. You can quickly find what’s causing the problem, verify the fixes with testing and benchmarks.
How do you speed up your WordPress site?