How to Speed Up WordPress: A Comprehensive Guide for 2016

Welcome to the mid-year guide to speeding up WordPress. We’ve crafted this 3500-word guide to enable you to adopt the best practices to run a super-speedy WordPress site.

A Guide to this Guide

We’ve split this guide into a couple of sections so that it’s easier for you to follow or catch-up, if you’re reading midway.

  • First off, we’ll talk about why being a speedy website matters. We’re pretty sure you’ve read about this tons of times, but nevertheless there might be someone who hasn’t – and this is exactly for that someone!
  • We’ll also cover the underlying technology. We at WPExplorer believe in understanding the reason behind a problem is the best way to solve it. That’s why in the past, we’ve written guides like Beginners’ Guide to WordPress’ Internal Functioning which attempts to give a basic understanding of how a few thousand lines of code can power almost 46% of the websites on the Internet. This section deals with the prime factors that affect your speed and general performance. Read this bit carefully, since with each factor, we’ll discuss the best practices.
  • We’ll then talk about performance fixes and optimization that applies to WordPress themes and plugins.
  • For the remainder of the guide, we’ve grouped the fixes by category like image optimization, database optimization and security fixes. We believe this categorization would help you understand and grasp the gist of the fixes faster – so you can get up and running in no time.

Okay let’s take a breath! We’ve finished the 200-word prologue. Now let’s get started with the guide.

Why Page Speed Matters

speed-1249610_1280

I’ll try to keep this short. We all know that everyone likes a speedy website. You’ve also probably heard that Google nowadays prefers a fast website over a slow one – which means that a faster website yields better SEO scores. Although there is no definite explanation over this, most videos and interviews tend to point to this plausible explanation.

People search for things they need immediate answers to. So a top hit must load quickly. Google simply cannot put a slow site upfront as it would make a poor search experience.

Imagine the first page in a Google SERP taking 10+ seconds to load – chances are you’ll leave the site before 5 seconds of waiting.

Studies have shown that for every one extra second added to your website’s loading time, you lose out on 7% conversions, 11% page views and an overall 16% decrease in customer satisfaction. Club all of that into one sentence you get this –

Decreasing your website’s load time by 1 second could earn you an easy 7% increase in profits.

I hope the last 178 words were able to convince you because that’s what we’re going to get. Let’s get started with the actual guide.

Underlying Technology

What makes a website slow? The answer to that question is lies in a multitude of factors – the most significant of which we’re going to discuss below.

Static vs Dynamic Websites

This comparison is best explained with a painter/photographer analogy. To support our example, let’s assume that both of them are asked to show a photo of a cat. The painter must always draw the picture, whereas the photographer can simply show you the photograph of a cat he clicked.

Who do you think will win in a “show me a picture of a cat ASAP” contest?

It’s the same with static and dynamic websites. In static websites, the resource – or the photographer’s picture of the cat –  is always present. One simply needs to open it to view it.

However, in the case of a dynamic website, the website needs to be generated every time someone wants to view it – similar to the painter, who needs to paint the photo of a cat every single time! This tells you that static websites are inherently faster than dynamic websites.

Static websites are inherently faster than dynamic websites.

A content management system – like WordPress – falls under the category of dynamic website generators. It is a software is designed to create and maintain a website with an admin panel for managing activities. Activities like adding a new post, page, etc.

Most people choose WordPress over static websites. It’s a good trade-off.

All the data is saved in a database server (an example of which is the popular MySQL server) and the media files (such as images and documents) being saved in the web server itself. Check out this article on WordPress’ internal functioning which discusses this topic in greater detail.

On the flip side, dynamic websites are a blessing to mankind. Imagine having to manage 1000s of posts, pages, tags, categories and media files. Managing them individually would drive a person crazy.

That’s why most people choose WordPress over static websites. It’s a good trade-off.

Fix #1 – Enable WordPress Caching

w3-total-cache-wordpress-plugin-wpexplorer

Caching is simply “saving a result for future use”. WordPress generates a webpage dynamically, each time a visitor requests for a page. What if it were to save such a dynamically generated page and serve it to the next visitor without having to generate it again? This would result in a much faster page load time.

This process is called caching and WordPress uses this technique in multiple places of its internal functioning. You can also enhance the level/amount of caching of other WordPress processes, using a caching plugin like W3 Total Cache, WP Super Cache or WP Rocket.

Fix #2 – Enable Gzip Compression

This is a simple compression technique that reduces the size of data to be transferred – hence increasing the speed. The caching plugins mentioned earlier will allow you to enable Gzip compression. For example, you can enable Gzip compression in W3 Total Cache under the Performance > Browse Cache option.

Fix #3 – Upgrade your PHP Engine

WordPress runs on PHP, which means it relies on PHP to execute its code to generate web pages. PHP is an open-source software that’s installed alongside webservers. The version of the PHP engine plays a tremendous role in determining your WordPress website’s performance.

The folks over at Kinsta Managed Hosting performed a benchmark of the PHP engines on WordPress 4.3.1 and this is what they found:

PHP WP Benchmark

PHP Benchmarks on WordPress 4.3.1. Source: Kinsta.com

# PHP Engine Transactions/second
1 HHVM Repo Authoritative 375.48
2 HHVM 357.69
3 PHP 7 306.24
4 PHP 5.6.16 106.45

The results are staggering. If you compare PHP 7 and 5, you’ll see a huge difference – PHP 7 is 187% –  almost 2x –  faster than PHP 5.

PHP 7 is 187% faster than PHP 5

HHVM is a PHP engine developed by Facebook. Only a handful of webhosts offer this engine since and it usually comes with a stiff price tag. However, PHP 7 is relatively simple to implement. Most shared hosts don’t go through the trouble of upgrading to PHP 7.

Upgrading also has a slight downside – a few old, highly inefficient functions are deprecated – meaning they aren’t supported anymore. If your WordPress theme were to use such functions, the PHP engine would encounter random errors.

That being said, most modern themes don’t have this trouble. If you want to upgrade your PHP version, you’re go to have to manually punch in a request. The good hosts proactively do this for you. Which brings us to our next topic.

Fix #4 – Choose your Hosting Wisely

WPEngine Hosting

Almost everyone reading this article knows the difference between a shared host, a VPS and a dedicated host. Let’s take a look at the new types of hosting.

WordPress Optimized Hosting – these are like revamped shared hosting plans fine-tuned for WordPress. This means that the server environment is optimized and ideal for hosting WordPress. But the resources are still shared which means under heavy traffic, the website might fail. This is a great hosting choice for new WordPress blogs/websites.

Managed WordPress Hosting – This is the absolute best of WordPress hosting. They take care of each and every aspect of your WordPress hosting – right from server optimization to creating a list of disallowed plugins. The use the most advanced combination of caching technologies, PHP engine, web servers, CDNs, backup software and a whole lot of other amazing stuff to deliver the absolute best hosting experience – which remain steady even during traffic spikes. This is great for medium/high traffic websites.

WordPress Cloud Hosting – there is another genre of hosting which leverage the infrastructure of cloud providers like Amazon AWS, Google Cloud and Microsoft Azure to host WordPress sites. What this means is that your WordPress site will be hosted on the cloud and the installation/configuration part will be done by the company. This is an excellent choice for people with cloud hosting experience or who want to take it up. CloudWays is one such company which hosts WordPress in AWS and Google Cloud. Check out our review of CloudWays for more information.

Of course, the cost of these hosting plans are anywhere between 20 to 70% greater than their traditional counterparts, but the returns are just as fruitful.

Fix #5 – Pick an Optimal Server Location

A server’s physical location plays a major role in the loading time of a website. If most of your visitor are from New Jersey, it wouldn’t make sense to pick your server in a datacenter in Singapore, 9500 miles away. While this would not make much of a difference to a single file of 1GB; it would make a tremendous impact on 100 files on 10MB each. Therefore, pick a server location closest to your target audience.

Fix #6 – Use a Content Delivery Network

load-time-animation

A simple GIF explaining what a CDN does. Source: MaxCDN

A CDN is a direct extension of the server location concept. Its aim is to replicate your WordPress site’s data (media files, CSS and JS files) across multiple servers across the globe. These replication locations are called Points of Presence of POP. The larger the number of POPs, the better the CDN network. We recommend MaxCDN as one of the most reliable and cost-effective CDNs in the current market.

The Client Device

In a world where there’s more Google searches in mobile than desktop, it’s a fair assumption that a good part of your users come from mobile devices. The growing importance of client devices are due to the fact that web developers are deferring some of the processing load on the client’s browser.

This means that your mobile user experience should be just as important as the desktop. Your theme might be responsive – but does it function smoothly in in mobile view?

Fix #7 – Optimize your Mobile View

How does it function in an older device? While Apple might be launching a new iPhone every September, a lot of folks still use a 4-year-old iPad – does your website work well there?

iPad Usage Breakdown

iPad usage breakdown. Source: david-smith.org

You might have heard of a term “graceful degradation”. Although it may not apply to WordPress, it is good to have an idea. It basically means serving a stripped down version of your website to devices which cannot handle the heavy, feature-rich version. It enables users with old/legacy devices to view the most important bit of content without the “toppings”.

A classic example is the BJ Lazy Load plugin which uses JavaScript libraries to show images only when it’s visible in the viewport. If a browser does not support JS or has it disabled, the plugin gracefully degrades – i.e. it stops its main function and loads the images normally.

Check out these mobile optimization plugins to get a fluid mobile site.

WordPress Extensions – Themes and Plugins

The concept of themes and plugins have significantly contributed to WordPress’ popularity as a CMS. While most of the popular plugins and themes follow best development practices, there are some which don’t. Let’s discuss a few examples where development practices affect WordPress site performance.

Fix #8 – Choose your Theme Carefully

total-main1

When it comes top premium WordPress themes, you need to tread carefully.

Pirated Themes? Absolutely not. There It’s no secret that you can obtain a pirated copy of the latest version of a bestselling Themeforest theme – rather easily I might add. But here’s the catch – there are high chances that the pirated theme has malicious scripts embedded in them, which is invisible to even an advanced user. Only trained developers with years of experience can detect such scripts. Malicious scripts are designed to steal your customer’s data (credit cards, emails, addresses, etc.), inject malicious files to your visitors and use your server to send out spam emails, among other activities. Before you know it, you’re banned from Google, and your reputation and credibility has plummeted.

Well Designed Themes? Yes. How do we define a good theme? Is it the design? Is it the typography? Is it the responsiveness? The list goes on. Fact is, design is a highly subjective matter. It communicates your brand’s image to the audience.  We leave that to your judgement.

We want to tackle the technical aspect of a well-designed theme. It should:

  • Be lightweight – the smaller the theme, the faster it loads.
  • Have fewer requests – smaller the number of requester, faster the site loads. It also reduces the effect of distance between server and visitor.

We compared the Parallax Pro theme from StudioPress and our very own Total theme. Here are the number of requests in each.

Theme No. of Requests Load Time Perf. Grade Pingdom Result
Parallax Pro 19 1009 ms 75 Link
Total 21 506 ms 87 Link

Genesis Test

Benchmark Result for the Parallax Pro theme from StudioPress

total theme test

Benchmark Result for the Total Theme from WPExplorer

The Total theme was hosted on WPEngine’s superfast managed WordPress hosting environment which gave it a 50% lesser loading time and 12-point higher performance grade.

Tools of the Trade

05 theme check wordpress plugin 2016 wpexplorer

  • You can use Pingdom to measure the number of requests your WordPress theme uses.
  • The Theme Check plugin can verify whether the active theme is adhering to the best practices.

Fix #9 – Use the Right Number of Plugins

36 p3 performance plugin wordpress plugin 2016 wpexplorer

The right plugin can extend the feature set of WordPress to incredible heights. On the flip side, too many plugins can impact performance. Think of it as installing too many apps on your phone. It drains the battery faster and slows your phone down over time.

  • Plugins like Theme Check or P3 Performance Profiler are used once in a while – then why keep them activated forever? Activate – use – deactivate. That’s the plugin philosophy performance enthusiasts should be following.
  • The P3 Performance Profiler plugin that made it to our 50 Essential WordPress Plugins list, measures the performance impact of the active plugins in your WordPress site. Keep deactivating your plugins until you reach a stage where deactivating even a single plugin will break down a component of your site.

Talk about no. of request from WordPress themes. What makes a good theme? Guide to building a good theme? What is a theme framework – why do we need one?

Fix #10 – Get Rid of the Fluff

This could mean a number of different things to different people. We have seen that a lot of these websites appear way too cluttered with gorgeous design elements. But people who are regular visitors generally don’t care for this stuff – and sometimes it might be unpleasant to see the same time-consuming design effects take place over and over again.

From the performance standpoint, these design effects add to the number of scripts to be loaded along with the theme – which in turn, increases the loading time.

Image Optimization

You might have read about optimizing images for the web – like compressing them or saving as progressive JPGs. IrfanView and TinyPNG are excellent tools for that purpose. But you can do more.

Fix #11 – Shrink all Images

09 wp smush image optimization wordpress plugin 2016 wpexplorer

But what about the tons of images that are already uploaded? That’s where the image optimization plugins come in handy. They scan and optimize your image library and take care of all future image uploads – so you don’t have to do them manually. Examples include: WP-Smush.itEWWW Image Optimizer, or Hammy.

Fix #12 – Defer Image Loading

08 bj lazy load wordpress plugin 2016 wpexplorer

We’ve mentioned the BJ Lazy Load plugin earlier in this guide. You can defer the loading of images only when they are visible in the viewer’s viewport. In other words, the image will start loading only when the visitor scrolls down to view it. This has multiple benefits:

  • First, it reduces the number of initial requests – be deferring the image requests when needed
  • The size of the page decreases, which results in faster loading time
  • Deferring the images saves bandwidth for both the visitor and the server.

Fix #13 – Disable Image Hotlinking

Remember freeloaders? Well hotlinking is like freeloading. People who hotlink to your site simply paste the URLs on their website. The image is displayed on their end, but the bandwidth cost is borne by you.

That’s a double loss right there – you pay for the bandwidth and don’t get any visitors in return. Here’s how you can prevent image hotlinking in WordPress.

Fix #14 – Define Image Sizes

You theme has a predefined maximum image width for every screen size. It is rather inefficient to serve images greater than the maximum resolution. You can manually set multiple sizes of your images with the add_image_size() function. When an image is uploaded, WordPress will make multiple copies of it in different sizes – one for thumbnail, post icons, etc.

Database Optimization

Just like your images, it’s important to optimize your site database for optimal speed.

Fix #15 – Optimize your WordPress Database

26 wp-optimize wordpress plugin 2016 wpexplorer

Over time, your website gets crowded with non-essential stuff. Like data from deleted plugin metadata, past theme changes and post revisions. This could leave hundreds of rows in the database unattached to any element. The WP-Optimize plugin does a fairly good job of cleaning up the WordPress database of such unnecessary elements.

Fix #16 – Limit Post Revisions

While I prefer to use Microsoft Word or Google Docs for writing articles, a lot of us prefer the good ol’ WordPress Visual Editor. WordPress automatically saves multiple revisions of each post so you don’t lose your work when the Internet breaks. However, that has a slight disadvantage.

Every long post is bound to have multiple revisions. These keep cumulating and ultimately increases the database size. Ironically, you won’t be needing these post revisions in the future. Therefore, you can limit the post revisions to – let’s say 3 – and save up space in the database.

To limit post revisions, simply paste the following code in your wp-config.php file.

define( 'WP_POST_REVISIONS', 3 );

Fix #17 – Empty Thrash More Often

While WordPress empties the thrash every 30 days, you could set the purge limit to 7 days and keep to keep your database nice and squeaky. Again, paste the following code in your wp-config.php file:

define('EMPTY_TRASH_DAYS', 7);

Fix # 18 – Ensure Efficient Database Calls

query monitor wordpress plugin

First of all, developers must avoid raw database queries in WordPress. There are legions of functions at your disposal to get everything from posts to comments, custom taxonomies and metadata.

However, if a developer must query the database, he should do so using the WPDB class, for maximum efficiency. Complex, resource intensive functions like table joins should not be done on the database as it would negatively impact performance. In many cases it is better to use two separate but far faster queries.

There are tons of tools such as Query Monitor to figure out if your queries are well written, and to see all queries run during a request.

Security Fixes

The three fixes described in this section have a security and a performance impact on the website.

Fix #19 – Prevent Brute-Force Attacks

15 login lockdown wordpress plugin 2016 wpexplorer

Attacks can come from anywhere at any time. It is your duty to hold a safeguard against them.

  • Login Lockdown is a plugin that limits the number of failed login attempts from a user. After three consecutive failed attempts, the plugin simply bans the user IP address – thereby preventing future attacks.
  • All-In-One WordPress Security and Firewall plugin is a comprehensive security suite for WordPress with various security features for new and existing users. The plugin deals with multiple vulnerable aspects of your site and ensures strict security is enforced among them.

Fix #20 – Eliminate Spam

antispam-bee-hero

Spam is a major concern for websites. Spam overloads your WordPress database and decreases your credibility as a webmaster. It needs to eliminated for good. While there are a ton of great plugins, the ones that stand out are Akismet and Anti-Spam Bee, amongst others.

Summary

Here’s a quick summary of all the fixes:

  1. Enable WordPress Caching
  2. Enable Gzip Compression
  3. Upgrade your PHP Engine
  4. Choose Your Hosting Wisely
  5. Pick an Optimal Server Location
  6. Use a CDN
  7. Optimize your Mobile View
  8. Choose your Theme Carefully
  9. Use the Right Number of Plugins
  10. Get Rid of the Fluff
  11. Shrink all Images
  12. Defer Image Loading
  13. Disable Image Hotlinking
  14. Define Image Sizes
  15. Optimize your WordPress Database
  16. Limit Post Revisions
  17. Empty Thrash More Often
  18. Ensure Efficient Database Calls
  19. Brute-Force Attacks
  20. Eliminate Spam

Conclusion

shutterstock_222191515-2

While it is important to optimize you site to peak performance – it is important to remember that speed isn’t everything. While it is certainly worthy spend money and decrease the loading time from 5 seconds to 2 seconds – it would not be optimal to spend double that amount to further decrease the time to 1.8 seconds.

Speed isn’t everything

Rather, that money could be better utilized in a promotional campaign. Let’s not forget – the ultimate goal of performance improvement is to gain more conversions.

This concludes our guide – thanks for reading and kudos on reaching till the end! As always, if you feel that a fix belongs up in this list – please let us know and we’ll have it up there in no time.

Sourav
Post Author: Sourav

Sourav is a WordPress enthusiast, an avid gamer and a sitcom collector. His playlists include heavy metal, electronic, and new-age tracks. When he's not online, he's spending quality time with his friends and family. You can follow him on Twitter.

Disclosure: This page contains external affiliate links that may result in us receiving a comission if you choose to purchase said product. The opinions on this page are our own. We do not receive payment for positive reviews.
Got something to say? Join the discussion.
  1. ruud says:
    In general a good article. However, you might want to check the plugins you're advising. Hammy hasn't been updated for over two years.
  2. Tushar Hossain says:
    I installed all plugins and using cdn too.. but my site is still slow :( What can I do?
    • AJ Clarke says:
      AJ Clarke
      You may have issues with your webhost I would recommend reaching out to them or switching to a better host.
      Admin
  3. Kişisel Blog says:
    Im using wp super cache plugin. Its very effective. You can add it to the list. Thanks for article.
    • AJ Clarke says:
      AJ Clarke
      Yes, WP Super Cache is great! We do mention it already in the "Enable WordPress Caching" section ;)
      Admin
  4. Vitalik Repin says:
    Do you know any plugins, which speed up not only front-end perfomance but also optimize google-related plugins (like google analytics).. It makes the google insight score of our website lower..
    • AJ Clarke says:
      AJ Clarke
      Your site speed "score" is useless. I would recommend using a site like GTMetrix instead and looking at the "waterfall" to see what is actually slowing down your site. The Google insight score is pretty much useless. You could have a site that has a score of 20 but load in 0.1 second or a site with a score of 100 that loads in 5 seconds. Actual speed is what matters. Don't worry too much about the scores ;) Most of the time your site speed depends on your webhosting so the first thing you want to do is make sure you are using a Good WordPress Host. There isn't any "magical" plugins that will speed up performance of your plugins but you can use the Plugin Performance Profiler to see what plugins might be slowing down your site.
      Admin
  5. Lucy Barret says:
    Good job Sourav. You have listed most of the things which are responsible for your site's loading speed. But most common problem is choosing poor web hosting provider.
  6. Emma says:
    1693 Shares for one article made me read this article thoroughly. I was curious what is unique in this article. So I went on reading this article. I really found the article useful I would highly recommend anyone who is visiting on this blog would read the article. If one really wants to gain something.
  7. Muhammad Usman says:
    Thank you for this article, right when I needed it! Speed and reliability are the most important factors to rank your website into higher positions on search engines. I was just facing this kind of issue thanks for your help. Keep it up
  8. Jyoti says:
    Thank you so much for this article. This helped to increase my site speed.

Leave a Reply