Speeding Up WordPress
Whether you’re using WordPress as a CMS, a blog or somewhere between the two, as a portfolio site, making sure your site runs quickly is absolutely paramount in this day and age. This article and screencast combo takes you through how to use a variety of tips, tricks and techniques in order to make your WordPress powered site load faster.
Contents
- Introduction
- Premium Themes Vs Custom Themes
- Optimising Images
- The 30%, 30kb Rule
- Using CSS Sprites
- Removing Database Heavy Plugins
- Caching Plugins Compared
- Setting Up W3 Total Cache
- Using a CDN
- Setting Up WordPress To Utilise A CDN
- Wrapping Up
Introduction
Since last year, page load speed has been included in Google’s ranking algorithm. Thus, it’s become absolutely vital that your site, regardless of its usage, loads as fast as possible. The first thing we’re going to do is test load speeds to see what point we’re starting from. I’ve taken two sites -- my fairly heavily optimised WPShout and my friend Marco’s blog, which runs a normal premium theme from ThemeForest. We’ll be using a tool called Pingdom throughout this article in order to test the speed of our site. To start with, we’ll compare the two sites -- the fairly heavily optimised WPShout and Marco’s blog, a normal WordPress blog running a premium theme.- Clearly, WPShout loads far faster than Marco’s blog and there are a number of reasons for this:
- Fewer files: WPShout loads with only a handful of CSS, Javascript and image files whereas Marco’s blog has a lot of CSS, Javascript and then a load more images added on top. We’ll cover optimising images later
- Faster files: WPShout is using a Content Delivery Network, or CDN in order to deliver the files faster. More on this, later.
- Cached files: you’ll note that images don’t show up as being downloaded again. This is because files which aren’t changed regularly are stored locally and so don’t need to be downloaded again. We get to caching later.
- Custom theme: WPShout runs a custom theme, whereas Marco’s blog runs an out-the-box premium theme. The pros and cons of each method are weighed up in the next section.
Premium Themes vs. Custom Themes
It’s obvious, but I’ll say it regardless: an out-the-box theme, free or paid, won’t get anywhere near the performance of a well made custom theme. Even premium themes from some of the largest marketplaces have horrendous performance. However, help is at hand! We can using something called a caching plugin in order to save a copy of your site and then show that when people visit, thus circumnavigating the problem of out-the-box themes using up a lot of resources. Imagine you had a written document and wanted to give copies to everyone who visited. At the moment, you have to write it all out by hand, but if you use a photocopier, you just need to do the work once and give out copies! A caching plugin is like the photocopier -- it loads the page once and then distributes copies of the page to visitors, meaning the page loads faster as visitors don’t have to wait for the server to load the page -- or for you to write out the document. There are a number of caching plugins available and we’ll visit them later.Optimising Images
- Images are likely to be the single biggest factor that slow down your site so are well worth taking the time to optimise!
The 30%, 30kb Rule
I use something we’ll call the 30%, 30kb rule. Images should be at 30% quality and/or no more than 30kb large. Whilst images containing text might need to be larger, as a general rule it works well in keeping file sizes down. Of course, you also need to make sure images are no wider than your post’s content area.Using CSS Sprites
- CSS Sprites let you combine what would have otherwise been multiple images -- and multiple downloads -- into a single file.
Further Image Optimisation
You can go further with your image optimisation, though. Yahoo has a service called “Smush.it” which takes your images and optimises them, keeping the same quality but lowering the filesize. It would be a pain to individually optimise each image so thankfully there’s an excellent free plugin called “WP Smush.it” which automatically runs all your images through Smush.it when you add them to a post or page.Remove Database Heavy Plugins
- Lots of plugins dosn't necessarily mean your blog will load slowly, but one may lead to the other.
- Plugins which make lots of database queries aren't a problem if you use a caching plugin.
Caching Plugins Compared
And now for the big one: caching plugins! These will give you by far the biggest performance boost but there are lots of plugins to choose from so it’s vital some time is spent comparing the performance of each on your site. Whilst there are a good number of plugins available, there are a couple of main ones: I switched to W3 Total Cache from WP Super Cache about a year ago after testing out various options and it’s been absolutely fantastic. That said, it’s not necessarily fastest on your site so it’s important you try out a couple and compare the results. Tutorial9 has a really good post comparing the different plugins available, but I must stress it varies from site to site which ones work best. However, I’ve found W3 Total Cache to be consistently fast on various set-ups so we’ll explore how to use it here.Setting Up W3 Total Cache
Installing such a complicated plugin is surprisingly easy. Total Cache installs like most other plugins -- under the plugins tab, do a search for W3 Total Cache and it’ll show up as the first result. Click “install now” and then activate the plugin. However, the plugin isn’t set up yet! You’ll see a new tab on your admin bar “Performance”. Open this up. Total Cache does some impressive detective work and gives you some recommend settings. It’s now just a case of going through all the settings, activating each one and seeing what performance boost each option gives you. Some may decrease performance so it’s vital you test. Total Cache has some excellent documentation built in -- select the various options under the Help tab. The FAQ is brilliant at going through more or less every single question you could possible have and answering it clearly. However, there may be some extra set up required. You might get some messages popping up at the top of the page telling you you need to add some code to a file called .htaccess. .htaccess is a file which allows you to locally configure your Apache settings, and thus is impressively powerful. To access it you’ll need to log into your site’s FTP and then navigate to the root. If you then can’t see it, show hidden files. Download it (again, show hidden files), make a copy as a backup and then load it in your text editor. Add the lines of code to the bottom of the file, upload again and you’re done! Make sure you try loading your site immediately to check it still works. If it doesn’t, check you’ve copied all the code exactly and you haven’t deleted any other code in the file. And you’re done! Total Cache is set up!Using a CDN
“A CDN can increase a website's performance by serving items from the closest possible location to the visitor. For example, let's say that you have a web server in Los Angeles. A visitor from the United Kingdom wouldn't get the best possible performance, because images and other content would go through many "hops" and a lot of distance to get across the USA and the Atlantic Ocean. With CDN, those items would be served from a location much closer to the visitor, e.g., Amsterdam. The web server would still provide the pages, but images and other larger items would be served from the CDN.” Mark Bailey, WPCDNEssentially, a CDN, or content delivery network, takes all your static files you’ve got on your site (CSS, Javascript and images etc) and lets visitors download them as fast as possible by serving the files on servers as close to them as possible. CDNs used to be for the elite, but in the last 18 months have become available to the masses and are now something I thoroughly recommend to anyone and everyone. The first thing you need to do is to find a CDN provider! CDNs to consider I use WPCDN on my sites and I’ve been very pleased with it, but by no means are they the only CDN providers! There are a fair few, but these are ones I’ve been personally recommended by others or use myself:
- Akamai
- Free CDN (this is, obviously, free, but I’ve had no experience with it; you may very well get what you pay for)
- Google! You can let Google host your jQuery/Javascript libraries for you on their CDN
- MaxCDN
- WPCDN
Goodness, that is a complete post – thank you! Will send bods over to study, inwardly digest and do it!
Very impressive post that will save me some time reviewing and writing myself – could not cover it better.
That you for this wonderful article, I really think Inspirationfeed needs alot of these.
Thanks for a great article and great tips for speeding up WordPress. W3 Total Cache is a awesome plugin that I recommend and it will give your blog amazing speed.
WordPress is great software (and FREE!), but it is slow.
On a basic install, very few plugins, most of the recommended speed tweaks applied, it still runs very slowly. Because of this and a desire for easier control over blog functionality, I decided to create my own basic blog using Symphony CMS (symphony-cms.com). Both are on the same server, and the Symphony blog runs much faster with no optimization.
I’ve noticed a huge difference in WordPress speed on different hosts. For example, I moved from GoDaddy to Site5 hosting recently, and all of my WordPress installs (4 small sites) run dramatically faster, without any hardcore optimization either.
Very comprehensive, excellent job! perhaps the only things we’re not utilizing on Insfired are CSS Spirtes & the “30%/30KB rule”. I don’t use the latter because I want to make sure images are of high quality.
Of course having a robust server, a CDN, W3 Cache & Smush.it makes even the largest of pages (more than 40 images) load in less than 10 seconds :)
Seriously, thanks for the great post. I develop a lot in WordPress and found this very useful.
Even though i know of shmush.it I think I need to start using it aha.
Many thanks for ALL this great info! Am not a developer and have been using Quick Cache and didn’t notice much improvement at all. Have installed shmush.it and OMG–what a difference it made! It reduced my existing images by only single digits but it makes a huge difference in performance.
Am currently running the query-debug plugin and feel empowered now. Many thanks and I look forward to more of your posts :)
Thanks Alex there are some really useful pointers in this post. With google increasingly using site speed as a factor in their algo all webmasters need to be paying more attention to full page load times.
We are really pleased that Alex’s post could be so helpful and that it has been so well received! Thanks for all the kind words and added thoughts.
Really useful list! Thanks! But doesn’t an image quality of 30% screw up your images too much? Especially when working with red colors?