Speeding Up Your WordPress Website

12 Ways to Improve Your Load Time


1.  Plugins

Plugins….. we all love them. There’s nothing more cuddly than a brand new plugin that supercharges your website. But we are all guilty of installing ones we don’t really need, or of installing a plugin, trying it out, deciding we don’t really need it and deactivating it,leaving it sitting inactive in our installation (nb – an inactive plugin won’t slow your site down but it will take up space. This will only cause you problems if you have restricted space). As is pointed out on this forum posteach plugin removal will speed up your website, even if it is only by a millisecond.
Here are some tips for plugin use for speedy-sites:
Okay, on a clean install of WordPress 3.1 with TwentyTen installed here is a site’s score with Google’s Page Speed Tool:
Speed score of 78/100
That’s okay. Not great but not dreadful either.
Here is the same install with 10 of WordPress’ most popular plugins activated:

Featured Plugin - WordPress Pop-Up Chat Plugin

No javascript required, no third part chat engine, just fully featured chat right in your own database on your own WP sites - couldn't be easier.
Find out more
Speed score 47/100
So much slower…… It’s not hard to see the difference that the plugins make.
NB: The plugins that I used for this test are: AkismetAll in One SEO PackContact Form 7,Google Analytics for WordPressJetPackNextGEN GalleryWordPress ImporterWPTouch,Yet Another Related Posts PluginAdd to Any

2. Cache

A caching plugin will make the biggest difference to your blog or website’s speed. If you are concerned about speed and don’t have one installed it should be the first thing that you do. Every time someone visits your website WordPress gathers up all of the information that it needs from your database. A caching plugin stores a flat HTML version of your website and, provided there has been no changes – a new comment or blog post, for example – serves that up instead.
There are a number of different caching plugins out there and it can be difficult to know which one to choose. The one that you go with will largely depend on what your website needs. Do you have a small website that needs a simple caching plugin for a small number of visitors? Or do you have large amounts of traffic and require lots of options to customize the plugin as you wish?
Here’s how my test site did after I set up W3 Total Cache:
Speed score 95/100
!!!! That is speedy!! W00t!
And this is interesting – with the same ten plugins installed as above, running W3 Total Cache check out the results:
Speed score of 86/100
That’s even faster than a clean WordPress install. I’m impressed! If you’re not caching –start!

Some Cache-Related Resources

3. Choose a Good Hosting Provider

This can be a difficult task – especially if you’re not familiar with the ins and outs of web hosting. Many people, when they set up their first website, will go with a popular and cheap shared hosting option like Host Gator and GoDaddy. I still have a number of sites on GoDaddy, which is where I started off my WordPress career – I’m actually in the process of moving my sites to a new provider.

Aside: Two Reasons to Avoid GoDaddy

How Do I Choose a Web Host?

4. Optimize Your Images for Web

Adobe save for web
One of my big bugbears is people not optimizing their images for use on the web. Why do they not understand that a 300ppi 9999999999px x 99999999999px is not necessary for a website? If an image takes a long time to load then I’m off. I don’t care if you’re selling the secret to eternal youth or have an image of the world’s cutest kitten. If it takes a long time to load – seeya later alligator!
Simply: Big image = big file size = slow load times

Featured Plugin - WordPress Infinite SEO Plugin

Fully integrated with the SEOMoz API, complete with automatic links, sitemaps and SEO optimization of your WordPress setup - this is the only plugin you need to help you rank your site number 1 on Google - nothing else compares.
Find out more
Don’t you understand that it takes much longer to load 300 pixels in an inch than 72???? Gah!
Anyway…..
The first thing you should do is ensure that the image is the right dimensions for your blog or website. WordPress does offer you the option to scale your images when you upload them but you are much better off doing it before uploading.  Our posting space here at wpmu.org is 550px wide so I always reduce images to those dimensions.
You should, always, always resample your image to 72ppi.
You can use one of these methods:

5. Farm Out Your Video

youtube screengrabUnless you’ve got a super–fast server with loads of space, hosting your videos on services such as Vimeo or YouTube can help with your speed. If you have a site with loads of videos then no doubt you’ve already taken server speed into consideration but if you are just posting the occasional video you should definitely host elsewhere. You can check out this interesting post on why you should use Youtube to host your video.

6. Optimize Your Database

Over time your database can get unruly. However, you can use the optimize function to clean up any wasted space that you have. It’s especially effective if you’ve recently just deleted lots of comments, creating lots of dead space in your DB. You should optimize your database at least once a month.
There are a number of ways you can do it:

a) Manually

Go to phpMyAdmin and select your WordPress database:
phpMyAdmin database
Check all:
Check all button
Select Optimize Database from the dropdown:
Dropdown menu showing optimize tables option

b) Plugin

WP DB Manager automatic settings

Featured Plugin - WordPress Facebook Plugin

Would you like to add Facebook comments, registration, 'Like' buttons and autoposting to your WP site? Well, The Ultimate Facebook plugin has got that all covered!
Find out more
A plugin like WP-DB Manager will take care of this for you – you can set it up to optimize the database regularly and, like many plugins, it comes with other great options that let you automatically back up your database and perform other database management tasks.

c) Cron Job

A cron job is an automatic program that you can execute at specific times and at specific dates. You can set this up through your CPanel. If you are trying to cut down on your plugins and want to be able to optimize your database you could set up a cron job to optimize your database on a regular basis. I definitely wouldn’t advise doing this unless you are comfortable administrating your database. For those who are, here’s a Cron Job code snippet which should get you on your way.

7. Choose the Right Theme

The right theme can make a huge amount of difference to your website’s speed. Themes with large amounts of images and scripts can slow down your website. Here are a few tips to help you choose a speedy theme (or speed up your own theme):

8. Use Excerpts and Limit Front Page Posts

posts graphicThis won’t be so relevant if you’re using WordPress as a CMS to power your website but it is important for bloggers, especially prolific bloggers and bloggers who write long, image heavy, posts. If you have them all feeding through to your front page you can expect to see your website slowing down over time. It’s obvious why this is – more data = longer load times.
You can mitigate against this by using excerpts and limiting the number of posts that load on the front page.

Limit Front Page Posts

Easy to do by going to Reading > Settings:
posts on homepage set to ten

Excerpts

To use post excerpts you’ll need to edit some code. In your index.phparchive.phpand category.php you’ll need to find the following line:

And replace with:

This means that you can now write custom excerpts for your post and have them displayed within your theme. If you don’t fill in the custom excerpt section WordPress will pull the first 55 characters from your post and use that instead.
You can change the word limit for the excerpt. Check out this post from WP Beginner for more details about how to do it.

8. Reduce PHP Queries

This one is a bit controversial so I thought I would include it. All WordPress themes contain some generic code which is used to pull data from your database. This can be replaced with static html.  So, for example, this:
 
Could be replaced with:
   My Blog – the best blog in the world, ever
This means one less query on your database. You could go through your whole theme and replace all of the unnecessary php calls with html.
Update: Check out Mike’s comments for why I, and others, are wrong on this one :)

Featured Plugin - WordPress Appointments Plugin

Take, set and manage appointments and client bookings without having to leave WordPress. Appointments+ makes it easy.
Find out more
Does this speed up your website? Not as much as a caching plugin. But if you’re trying to get speed from anywhere possible and you are diligent about changing it across the site then you could see a modicum of speed increase.

Why is this controversial?

There’s an interesting discussion on Lorelle’s blog (from way back in 2007) in which Matt and Otto dispute the effectiveness of replacing these queries with HTML. If you’re a speed-geek it’s an interesting discussion to read and there’s quite a lot of detail about the effectiveness of this technique.

9. Disable Hot Linking

Hotlinking is when another internet user uses an inline link to display an image that is hosted on your site. You know, those people who do a Google image search and not only think that it’s okay to use your image but also are fine about embedding the image using the link to the one you host, thereby leaching up your precious bandwidth.
You can ensure that this doesn’t happen by adding the following code to you htaccess file:
WARNING! Always backup your htaccess file before making any changes.
#disable hotlinking of images with forbidden or custom image option
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?yourdomain.com/.*$ [NC]
#RewriteRule .(gif|jpg)$ – [F]
#RewriteRule .(gif|jpg)$ http://www.yourdomain.com/stealingisbad.gif [R,L]
Thanks to Josiah Cole for this hack.

10. Clean up after yourself

An easy way to build up too much data is to not clean up after yourself. You should clean your WordPress website as regularly as you clean your house (which for me isn’t too regularly).

Trash

Your trash is cleared automatically after 30 days.  You trash a post and 30 days later it’ll be gotten rid of. You can empty the trash manually by going to Posts > Trash and clicking “Empty Trash” like so:
empty trash button
But, like everything else with WordPress, there is a way to do it automatically. Simply add the following to your code to you wp-config.php file:
define('EMPTY_TRASH_DAYS', 10 );
That will set it to empty ten days after trashing.

Revisions

As with emptying the trash, there is a number of ways to get rid of your revisions.
You can run a command on your MySQL database (make sure to back up before doing this). Log into phpMyAdmin, locate your database and run the following command on it:
WARNING! Backup your database before running any commands!
DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision';
(Thanks to Craig for that!)

Featured Plugin - WordPress Q&A Site Plugin

It's now incredibly easy to start your own Q&A site using nothing more than WordPress - The Q&A plugin simply and brilliantly transforms any site, or page, into a perfect support or Q&A environment.
Find out more
You can also use a plugin such as Better Delete Revision which will take care of it for you.
If you don’t use your revisions you can just stop WordPress from saving them altogether(only do this if you really don’t want them – I use my revisions quite a lot so would never turn them off).
To turn off your revisions altogether add the following to your wp-config.php
define(‘WP_POST_REVISIONS’, false);
If you want to just limit your revisions to, for example, 3, you can use the following code:
define(‘WP_POST_REVISIONS’, 3);
Thanks to Mike for that :)

11. Turn Off Communication

If you’ve got a big blog with a lot of traffic that people link to a lot all of that chatter could slow your website down. Trackbacks and pingbacks generate data on your website every time someone links to you. Turning these off can improve your site speed. This isn’t a difficult thing to do. Just log into your dashboard and go to Admin>Discussion and make sure the following is unchecked:
That’s just eleven of the ways that you can speed up your WordPress website. There areloads more ways to do it. If you’re still trying to improve your load time you should check out these great resources below which can help you even further.

Resources

Speed Testing Resources