Get 20% off all of our individual Pro themes or grab the entire club! Just use the coupon code CCTHEME20

Discover our superb new professional blogging WordPress theme, Jefferson Pro

Get the latest Create and Code updates and offers every month
Home Blog Speed How to speed up WordPress – Part 1

How to speed up WordPress – Part 1

Leave a comment

How to speed up WordPress – Part 1 Leave a comment

Welcome to Part 1 of our How to speed up WordPress guide. If you’re having performance problems with your WordPress website, you’ve come to the right place. Stick with us on this high performance WordPress tutorial series and I promise you by the end of this journey you’’ll be rocking a blisteringly fast kick ass WordPress website that leaves the rest of ‘em in the dirt 🙂

The importance of the speed of your WordPress website.

The speed of your website is incredibly important. Study after study clearly shows that users despise slow websites. And why wouldn’t they! In this era of information overload where our attention is being demanded from an almost infinite number of sources, we simply don’t have the patience to hang around a wait for a slow website to load. If you’re website is slow you’re losing sales, leads and generally annoying your users. Even if you’re not selling directly online, a slow website reflects really poorly on your business reputation.

Why is WordPress so slow?

If speed is so damn important why is it that so many WordPress websites are so slow? Seriously, not a day goes by where I see someone complain that their WordPress website is too slow. There’s a huge amount of confusion about why WordPress is slow. So let’s clear up a few things before we get into the thick of how to speed up WordPress. A little bit of background on the fundamentals will really help you understand some of the things we tackle in later parts of this tutorial series.

A quick primer on how your WordPress website gets displayed on screen

When you open a WordPress website, a whole series are events are triggered. Let’s fly through them so you have a better understanding of what’s going on under the hood. As we go we’ll be highlighting where the key bottlenecks can arise. Eliminating WordPress speed bottlenecks is the number one priority of this guide.

DNS Lookup

When I click on a link to yourawesomewebsite.com, the very first thing that happens is your browser has to figure out where yourawesomewebsite.com is hosted. Your domain name is basically a PO box number for where your website lives. Your browser is more interested in knowing the precise address of your website – which is called an IP address (which is a series of numbers like  66.155.40.249). The process by which your browser figures out the IP address of your website is called a DNS lookup. When you setup your website you would have had to configure your DNS records for your domain to point to your hosting company’s DNS records.

Let’s face it – DNS is pretty boring – so here’s an highly scientific illustration about what’s going on.

DNS - the science bit
DNS lookups – the science bit

This brings us to our first speed bottlenecks. The DNS lookup itself. Generally DNS lookups are pretty fast – they are after all the fundamental communications protocol for the entire frickin internet 🙂 But from time to time they can be slow. This can happen for many different reasons. You may have an issue with your ISP or your router which is leading you to believe your website is slow – when in fact the problem is limited to your connection to the Internet. This can often catch people out when they’re debugging why their website is loading slowly. Slow DNS lookups can be confirmed by switching your DNS to use something like Google’s Public DNS or OpenDNS. It’s also important to rule out your internet connection simply being congested – which is easy to do as all other websites will be loading slower than normal if that is the case. As your website grows it may be worth considering dedicated DNS hosting with anycast support like that provided by Easy DNS but in general it’s rare that your DNS lookup time will be a major speed bottleneck – but I always rule this one out initially when investigating a slow WordPress website – just in case 🙂

Web server requests

So now your browser knows where to go it will make a series of requests to the server. These are known as http requests – or https requests – depending on whether your website uses an SSL certificate (which we’ll come back to in a later part of this guide). In WordPress, everything gets routed through an initial request to your main index.php file in the root of your website. Your web server handles the processing of the requests from your browser. And here ladies and gentlemen is our second major speed bottleneck. And this one is a doozy! Your web server will more than likely be Apache or nginx – which together account for nearly 50% of all web servers globally for all websites. In just the WordPress ecosystem, I would estimate that well over 90% of all WordPress websites are hosted on either Apache or nginx – which Apache being the more conventional, incumbent choice. Although nginx usage has been growing rapidly over the last 5 years. (WordPress.com is one of the worlds largest nginx users). There are often heated debates between the neckbeards as to which is best.

The reality is that either are perfectly fine for WordPress – as long as they’re configured correctly. Your hosting company is responsible for your web server configuration and ultimately responsible for ensuring that their hosting infrastructure is managed and optimized correctly. Unfortunately this is where things get messy and complicated. Not all web hosts give the same care and attention to how they configure their web servers. What’s worse is that even if they do configure things correctly many web hosts get greedy and try to squeeze as many people as possible on to the same web server to keep their costs down and their profits up. The very big shared hosting companies have been notorious at overselling their web servers for years. It’s not uncommon that there are hundreds of thousands of websites hosted on some web servers of the largest hosting companies. If you’ve got a shared hosting account at a large hosting company like Bluehost, Hostgator or GoDaddy this is most likely where your website lives. If you’re paying $5 – $10 per month on shared hosting you will almost certainly experience speed bottlenecks on an ongoing basis even if your website isn’t getting a lot of traffic isn’t doing anything particularly performance intensive – simply because there could be any amount of crazy stuff going on with other websites on the server your website is hosted on.

We’ll be circling back to the different types of hosting plans you can avail of and how you can avoid speed bottlenecks with your web host in Part 2. Just now that his choice is probably the single most important choice you’ll make in creating a blistering fast WordPress website.

Loading WordPress core php files, plugins and your theme

Despite all the arguments about which web server is best, a well configured web server on a reputable web host is usually not a major speed bottleneck. Modern web servers are usually just controlling the flow of communication between your browser and the backend worker processes that actually execute WordPress. In this case, we’re talking about PHP itself. PHP has evolved massively in recent years. PHP was for the longest time a dog slow programming language. Huge speed improvements have been achieved in recent years thanks in no small part to Facebook of all companies. Facebook runs a huge amount of it’s services on PHP and a variant of the language they created called Hack. In addition, they also created a virtual machine called HHVM out of necessity to make their PHP code compile and execute faster – simply because all other options that existed at the time weren’t fast enough to cope with their global scale. These innovations in turn seemed to spur on the core PHP development team to create PHP7  which dragged PHP into the 21st century and closed the performance gap with HHVM. This means that the WordPress project (and every other PHP based project) have made huge performance improvements in the past 3 years on the back of the excellent work by both project teams.

Despite massive speed improvements in the core PHP language and run times, WordPress itself is a large legacy codebase that makes it difficult to harness all aspects of these enhancements. Furthermore, WordPress out of the box doesn’t ship with any built in caching mechanisms – which mean that if you’re running core WordPress every single page request will be hitting your database to generate a page or post. Which brings us to our biggest speed bottleneck of them all.

The Database

Simply put, 95% of all WordPress speed problems start and end here. It’s that simple. WordPress by it’s very nature is incredibly database intensive out of the box. If you fire up a simple load test on a naked WordPress install without any caching layers to protect it – it’s quite easy to kill it quickly simply by overloading the database with thousands of concurrent http requests.

Bill nails the main speed bottleneck for WordPress
Bill nails the main speed bottleneck for WordPress

As a result, the vast majority of tricks and tips we’re going to be using to speed up your WordPress website are about protecting your database and ensuring as many page requests can be delivered from somewhere else – anywhere else!  It’s crazy how many tutorials I see about speeding up WordPress that focus on things like minifying stylesheets or Javascript files and never once mention your database. Sure, minifying all the things is great and it does help – particularly with perceived load speed – but it’s small fry compared to the database. Get your database in order, optimized and protected and you’ve done 80% of the work you need to have the fastest possible WordPress website.

Delivering everything back to the browser

So once your database queries have executed the web server sends back http responses to the browser – which is the point at which the web page you’ve asked for is finally loaded on your screen. And this is our penultimate speed bottleneck. Simply put, the more ‘stuff’ that your WordPress website loads, the longer it will take for your webpage to load. In this case ‘stuff’ is:

  • HTML – the markup that comes from your theme and plugins, plus the content you’ve added to your posts, pages and widgets.
  • Images – the images coming from your theme, plugins and your content.
  • Javascript, CSS assets – all the ancillary assets that are responsible for layout, design and interactivity

In later parts of this guide we’re going to explore all the things you can do to streamline the amount of stuff your website generates.

Latency

Our final speed bottleneck is often overlooked but can be significant. Latency is the delay before a transfer of data begins following it’s instruction for it’s transfer. Geography is the biggest factor when we talk about latency. If your web server is in Amsterdam and your customers are in Europe – cool! You will more than likely have very few latency issues. If most of your customers however are based in Australia things won’t be so cool. I’ve been WordPress websites that load in 1-2 seconds in Europe take up to 15 seconds to load from Sydney! The good news is that latency is a reasonably easy problem to solve compared to some of the other bottlenecks we touched on early.

Looking forward to Part 2

Well done for making it this far! Now that we’ve got the fundamentals out of the way we can look forward to digging into the heart of how to speed up your WordPress website – stay tuned for Part 2 which is coming real soon 🙂

Subscribe to Create and Code via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Follow us on Twitter and Facebook!

Stay connected – be the first to get interesting updates and new releases from Create and Code.

Colm has been building web stuff since the web was a wee lad. Colm built his first blog with WordPress around 2007 and has been hooked ever since. When not knee deep in hooks and filters you’ll probably find him running around a mountain or making pizza.

Leave a Reply

Your email address will not be published. Required fields are marked *

Error: Please enter a valid email address

Error: Invalid email

Error: Please enter your first name

Error: Please enter your last name

Error: Please enter a username

Error: Please enter a password

Error: Please confirm your password

Error: Password and password confirmation do not match