10 Ways to Speed up Your WordPress Blog

imagebigger

If your site takes an age to load, in the words of Jeremy Clarkson, that’s not good. You don’t want to wear on your reader’s patience before they’ve even started reading.

In this post we’ll explore ten ways to speed up your site, with tricks ranging from easy to even easier; none of the stuff in this post is difficult, so there’s no excuse for a slow-loading blog after reading this!

1. Delete Any Unwanted Plugins

If your site is loading slowly, look at how many plugins you’re using. If the answer is more than ten, look at the plugins you’re using and ask yourself whether you can integrate them directly into your theme.

While you’re at it, also ask yourself whether you really need the plugin. If you can do without it, do.

2. Remove Unnecessary PHP Tags

If you’re using a theme that you didn’t make yourself, then chances are it’s full of php that doesn’t need to be there. For example, your header could have something like this:

This is telling WordPress to get the stylesheet url every single time someone loads your page. You can very easily replace this with something like this: (Remember to replace yoursite.com with your address).

This is just one example – there are many many more times you can do this – have a hunt round your header.php and other theme files and you’ll be amazed at the number of unnecessary queries you can eliminate. We have a list of 13 of the most common un-needed tags here.

3. Use WP Super Cache

One of the better known techniques for speeding up WordPress is to install the WP Super Cache plugin. It caches your site for super-quick loading. It’s as simple as that. Install it and forget about it (and then promptly remember it when you wonder why your design changes aren’t showing next time you edit your theme files!).

4. Optimise Your Database

You’d be surprised how much you can increase your load time simply by optimising your database. As always, you could do it manually or just get a plugin that does it for you!

The manual way. This is super easy, as I explained on my blog: login to cPanel, find phpMyAdmin, select your database, click ‘check all’ at the bottom of the page and then in the drop down box in the middle of the page (see the image below), select ‘Optimize database’. And you’re done.

optimise

The other option is to use a plugin: the Optimize DB plugin from yoast.com does what it says on the box.

5. Optimise Your Images

If images aren’t optimised, both your blog’s bandwidth and load time will be affected. Both are bad. The solution? Optimise your images. It’s easier than you may think; in Photoshop click ’save for web’ under the file menu or in the free GIMP, save the file as a .jpg and you’ll automatically be given the option to compress your image.

As a benchmark, although obviously depending on what the image is, on my blog I aim for in-post images to be 40kb or less (although don’t sacrifice quality too much!).

If for whatever reason you can’t use an image editor, all is not lost! Yahoo have a free service called smush.it that you can point at a web page and it’ll optimise the images.

6. Compress your CSS and JavaScript

Again, something that is very easy to do: compress your CSS and put your JavaScript into a single file.

To compress your CSS, you can use an online tool, such as styleneat.com (see the image below), which will get rid of the white spacing and neaten everything up. You might not notice any difference to start off with , but it will make a difference to your blog’s load speed; these things all add up.

Something else do is to put all of your JavaScript into a single file and then load it at the bottom of the page (in the footer.php file). This ensures that the styling is loaded first, then any fancy JavaScript you’ve got loads last.

styleneat

7. Disable Hotlinking

As I said earlier, if your images aren’t optimised then your using up bandwidth unnecessarily. It’s bad enough having to keep images optimised for your own server’s sake, but say someone else copied and pasted the url of the image, putting your images on their site?!

That’s called hotlinking, and via the .htaccess file (which you’ll find in your root directory), disabling hotlinking is easy.

First, backup your .htaccess file. I can’t stress how important that is! Next, add the lines of code below, changing the appropriate lines to suit your blog. The last line is an image that will display instead – how about an advert for your site?

1.#disable hotlinking of images with forbidden or custom image option
2.RewriteEngine on
3.RewriteCond %{HTTP_REFERER} !^$
4.RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC]
5.#RewriteRule \.(gif|jpg)$ - [F]
6.RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/stealingisbad.gif [R,L]

Source – A to Z of WordPress .htaccess hacks.

8. Keep Spammers Away

The .htaccess file is a very useful tool (e.g. here’s some of the best htaccess tricks); it won’t just stop hotlinking, but it can also be used to keep spammers away by blocking referrers from certain sites. At this point, you’re probably thinking “great, pity it’d be impractical to implement this.”

Well, yes, it would be. The good news is that over at Perishable Press, Jeff has complied a list of over 8000 of the web’s spammiest referrers, which you can download here and just copy and paste into your .htaccess file.

How will this help your site load faster? If spammers aren’t getting onto your site then they aren’t using up your resources, freeing them up for everyone else to use, so the site loads faster. It will stop spammers from baraging your server with hundreds of requests. You can read the full explanation on the post at Perishable Press.

9. Turn Off Post Revisions

Post revisions, introduced in WordPress 2.6, haven’t been a big hit with everyone, especially those with single-author blogs. Why do they slow down your site?

Every single time you save a post, a new row is created in your wp_posts table, so if you save your post ten times, that’s ten new rows created.

Thankfully, as Lester Chan points out, it’s easy to turn off post revisions – add the following line to your wp-config.php file:

10. Your Thoughts and Additional Reading

A couple of other articles around the net to check out -

AndBreak.com: Guide to Speeding Up WordPress

WPCandy: 4 Simple Ways To Speed Up WordPress

Lorelle on WordPress: The 3 Easiest Ways to Speed Up WordPress

Yoast.com: Speed up WordPress, and clean it up too!Speed up Wordpress, Increase Wordpress Performance

Noupe.com: 13 Great WordPress Speed Tips and Tricks for MAX Performance

Everyone’s got their own ideas: what’s your favourite way to speed up WordPress? Leave a comment below.

Share

  1. Andrea_R (19 comments)3 June 09

    Just a note about step #4 – if you click “check all table with overhead” those are the only ones that need optimizing. It doesn’t hurt to check all, just adding some clarification because they use two words for the same thing. :)

    Andrea_R’s Latest Post: ComLuv Beta

    • Alex Denning (17 comments)3 June 09

      Thanks for the clarification :D .

  2. Looks like bullet #9 is missing the code…

    Joey Sichol’s Latest Post: Trying to make it through this…

    • Alex Denning (17 comments)3 June 09

      Yeah. Michael said he’d fixed the problem – there was a problem with contributors displaying code; I’ll drop him an email.

    • Matt_H (2 comments)18 November 09

      #2 is missing is also missing the two lines of code.

      I’m pretty sure the first line of code is:

      …For example, your header could have something like this:
      <link rel="stylesheet" href="” type=”text/css” media=”screen” />

      And the 2nd line of code is:

      …You can very easily replace this with something like this:

    • Matt_H (2 comments)18 November 09

      [EDIT] Guess I can’t put the code in comments either.

  3. I wonder if we disable hot linking does this stop images from appearing in the site feed, i have seen lot of blogs whose images dont load in Feed Reader, and i thought this trick had disabled images from display, is that true?

    • David Airey (55 comments)3 June 09

      It is true. You can get around it by “whitelisting” specific sites with an additional line of code. You’d want to add Google (for the image search), and any feed readers of note. I tried it a while back, but eventually gave up because there are too many different readers used by my subscribers, and I was anxious about missing some.

      David Airey’s Latest Post: Ten logo design tips from the field

  4. David Airey (55 comments)3 June 09

    This is a good reminder for me. Thanks, Alex.

    I’m one of you who didn’t take well to the “post revisions”. Even though I turned them off, I still get an occasional message in the admin telling me there’s a more recent version saved. Once or twice it messed up my post, but maybe it’s just my noobness.

    David Airey’s Latest Post: Ten logo design tips from the field

    • Ashfame (1 comments)14 August 09

      Its probably a bug or something that on some installations post revisions can’t be turned off.

    • It’s not a bug, it’s by design.

      Turning off post revisions in Wordpress doesn’t disable the Autosave feature (which is also stored as a revision but there is only one per post).

      You probably had a newer autosave when you received that message.

      PS. You can disable Autosave but I wouldn’t recommend it as it also updates security nonces in the admin.

  5. #6 Compress your CSS and JavaScript
    YUI Compressor is really good for compressing JavaScript and CSS http://developer.yahoo.com/yui/compressor/
    If you happen to use Visual Studio for development you can also add it as an external tool to create a button to get the job done easily http://blog.lavablast.com/post.....tudio.aspx

    Thomas Curran’s Latest Post: What ever happened to microsoft Sam?

  6. Nishadha (3 comments)4 June 09

    Thanks you for this great set of ideas , As you have mentioned every bit adds up load time is very important to the success of your blog. I use a plug-in called WP Optimize ( http://www.ruhanirabin.com/wp-optimize/ ) and I think it provides a good solution to points 4 and 9.

    Nishadha’s Latest Post: Free Twitter Tools to Manage your Twitter account

  7. These are wonderful, wonderful ways on how to speed up our WP blogs. Very useful information, I’m sure this will be a big help to lots of bloggers. The WP Super Cache is really great at speeding up the loading time, use the other ideas here and one could really increase the loading time significantly. Thanks!

  8. Over all, a good articles, marred only by having some of the examples missing — #2 and #9

    Wayne Smallman’s Latest Post: 78% of Gen Y is ‘Meh’ About Twitter; They Also Retweet Less – MarketingVOX [del.icio.us]

    • Alex Denning (17 comments)5 June 09

      Haven’t had a reply to my email, so here we go:

      #2 – your header file might have something like this: (off the top of my head so might be a bit wrong)
      and replace it with /wp-content/themes/yourtheme/style.css

      and #9 just click the link to Lester Chan’s site and you can find the code.

  9. Joe (5 comments)4 June 09

    I would like to Compress the images at web-site or blog… if you want to know more about it read at my blog…

    Joe’s Latest Post: 7 Ways To Become a Better Writer

  10. TeMc (2 comments)4 June 09

    From both #2 and #9 the code is missing.

  11. Kimber (3 comments)4 June 09

    Great tutorial! I’ve been having issues with speed on my godaddy account.

  12. Great tutorial. Is very useful for beginners, but also for professionals because sometimes you forgot some steps. Thanks

    Adrian – WPDONE’s Latest Post: SimplePerfect – A Free Premium Wordpress Theme by wpdone

  13. Jestep (3 comments)5 June 09

    Make sure you are hosting on a decent server, with a decent connection. It doesn’t matter how much optimization you do, if your server has 10 bottlenecks. Additionally, if you continuously grow your site, godaddy, and pretty much any cheap host is going to be unacceptable. Once your traffic gets high enough, move to a semi/dedicated, or VPS server with a good connection.

    Jestep’s Latest Post: Multi process PHP execution

  14. Great article will link from my website. I get asked about speeding wordpress all the time :-P I take code out of the theme and put it into widgets. I don’t recommend hard coding themes as customers do like to change themes and not break their site features.

  15. Interesting, I’ll be doing this to my blog soon, thanks :D

    Alex Brooks’s Latest Post: How you can use Myspace to get more downloads!

  16. SEO Indore (1 comments)8 June 09

    I use WP Super Cache plug in. This is very nice plugin.

    Thanks for sharing These tech.

    SEO Indore’s Latest Post: What is Google Sandbox effect ?

  17. I didn’t know about hot linking so thanks for sharing. I also have to thank you for listing my article in your very thorough post.

  18. Kalebarkab (1 comments)9 June 09

    I want to find good pop music. Help me please.

  19. Thank you very much for this post.

    FreewareMatter’s Latest Post: CamStudio 2.0 – Popular screen recorder

  20. Bjarni (2 comments)11 June 09

    I like point 8, thanks for that : )

  21. Fazai38 (1 comments)11 June 09

    So useful!!.. I face Wordpress memory over used problem.
    I will try out all of them … Thanks for sharing.

  22. Amazing tips! ;)

    Pablo Almeida’s Latest Post: DE NOVO: O site está em reformulação!

  23. Seems the second link to my site isn’t working. Good article though and thanks for the links :)

    Joost de Valk’s Latest Post: Custom RSS feeds in WordPress

  24. emonweb (1 comments)11 June 09

    Yes nice post. have some clue to explore more. thanks for your effort.

  25. Kris (1 comments)11 June 09

    Thx for the article, very usefull. May be next time can bring more tips….

  26. unimax SYSTEMS (1 comments)11 June 09

    very useful article this will help my clients to speed up their WP.We customize WP for our clients.

    Saleh Galiwala
    unimax SYSTEMS
    salehgaliwala@unimaxsystems.info

  27. Franklin (1 comments)11 June 09

    Great article! I will definitely be implementing these and hopefully it will speed up my wordpress blog. The htaccess trick is going to be awesome for advertising as I notice, through analytics that my pictures are be hotlinked.

  28. This article is a huge help, especially since we’re going to be even more video-heavy than we are now: every bit of speed helps! thank you.
    Terrintokyo´s recent postEigobama.com presentation at Tokyo2Point0

  29. Sarah (7 comments)20 June 09

    I am not familiar with these codes and all but I hope I am implementing it in the right way.
    .-= Sarah´s last blog ..Freelance Writer – 3 Reasons Why You Need a Blog =-.

  30. i9do (2 comments)22 June 09

    嗯,写得不错,有些借鉴价值。。。

  31. Hey, this is just a heads up. Just wanted to let you know that Speed up WordPress, and clean it up too!Speed up Wordpress, Increase Wordpress Performance under Number 10. Your Thoughts and Additional Reading actually links to Earnersblog DiggProff Your Wordpress. See about fixing that.

    I’m skeptical about adding Number 8 to my site. I installed Bad Behavior as a recommendation from the guy of Wp- Supercache and got a shocker when I couldn’t log into my account at home. My uncle’s IP was listed as a spammer. I had to FTP and delete bad behaviour before I could gain access to my site again.
    So I’m kinda wondering what would happen if I include this list in my .htaccess file and can’t access my blog or block legitimate surfers who are surfing from an illegitimate IP address.

    Finally, should I finally decide to give it a try, which of the .htaccess files do I need to modify? Do I need to create a new one? And where does it have to be in my server to work?

    Thanks man. Hope this ain’t asking too much.;)
    .-= Udegbunam Chukwudi´s last blog ..How To Secure Your Download Files And Bandwidth =-.

  32. Andrew (6 comments)27 June 09

    Excellent tutorial – can’t wait to try these tricks!

  33. Artyom (1 comments)28 June 09

    Thanks for tutorial. Try to use that in my blog!
    .-= Artyom´s last blog ..Астрономические наблюдения Венеры =-.

  34. Nice post m8…

    I downloaded the plugin from Yoast.com and the WP Super Cache, and they speeded the website up alot, thank you alot…

  35. Ryan (7 comments)30 June 09

    Great tips!

    However #9 is a bit “theoretical”. Sure it might have helped 10 years ago on an early version on MySQL 2 or 3 but on any modern database this effect will be absolutely negligible.

    For instance I just ran a query pulling a row of data out of a table containing over 20 Million rows and it took .0005 seconds [Showing rows 1 - 1 (20,169,779 total, Query took 0.0005 sec)]. Compaere that to another table that has 14 rows and we get [Showing rows 1 - 1 (14 total, Query took 0.0005 sec)].

    A proper database is designing specifically for pulling single rows out of many… it’s what a database does. Disabling post revisions just doesn’t gain you anything in a real world application.Revisions is a great feature for wordpress in case you mess something up and there is really no need to disable it.

  36. CuteA (1 comments)1 August 09

    I just Optimized my web site using the instructions given here. Now it is loading much faster. Thank you for the valuable article.
    BTW I disabled hotlinking through my host provider and not by the code given here. Will that be okay?

  37. Theres a smush.it plugin for wordpress i’ve been using for a couple of weeks. It’s pretty damn helpful too, I can upload images without worrying if they will take 5minutes for my users to load as wordpress resizes them and the plugin smush’s them. Its currently one of my favourite plugins and there are some good tips you’ve suggested in this post too.

    Thanks

  38. Good tips, i always try and keep my images small, for the reasons already mentioned above.

  39. You can do all client side improvements automatically and save time by Web Optimizer plugin, http://wordpress.org/extend/plugins/web-optimizer/

  40. thanks for nice guide, and special for “disable hotlinking of images”

  41. nice information..thank you for share

  42. While this article isn’t really 10 ways to speed up a Wordpress blog, it does contain some nice tips and tricks.

    Is the reason your Wordpress blog is so slow really due to hotlinking or post revisions? No of course not!

    This doesn’t stop the ‘good’ information from being ‘really good’, however. Use WP Super Cache, streamline your code and compress your css and js and your blog will fly.

  43. This article is definitely a huge help. While my blog isn’t as big right now to need any optimisations for speed, but well, it can never be fast enough. Looking forward to more such wordpress optimization articles.

  44. Dave (15 comments)29 December 09

    I don’t think wordpress can’t handle upwards of 250,000 posts. my site is crawling and it’s on VPS :(

Leave a Comment

Your reply will be added to the comment above (Below any other replies to this comment) -

(We DoFollow)

Not sure how to get an image with your comment?