Speeding up that WordPress blog

Posted by Lyndi

WordPress blogs are on average pretty slow loading. Fortunately there are a number of ways of speeding up a WordPress blog. Today I would like to take a look at a quick and simple way that could make a big difference.

If you open up your header.php file you will find markup similar to that illustrated in the graphic above. All the markup with the red bits (on this graphic) are PHP code to get various bits of information from the database.

One of these PHP calls is the following:

<?php bloginfo(’stylesheet_url‘); ?>

This is a PHP call to the database to find out in which directory the stylesheet is located in. Every blog is different but there are quite a few of these database calls in the Head section of the header.php file. I have just used the stylesheet directory as an example.

Every time a page is opened in WordPress the header.php file is called. Everytime this happens all the mentioned calls to the database are made to get the required information. This is normally coded this way so that the relevant theme can be used across multiple blogs without having to change the markup.

If you replace these database calls with the actual information required, WordPress will not have to call the database to obtain the necessary information for each of these instances.

If you right-click the main page on your blog and read the code of your page you will see that the real directory to the stylesheet directory is something like:

href="http://nice2all.com/wp-content/themes/nice2all/style.css">http://nice2all.com/wp-content/themes/nice2all/style.css

The code will show all the actual information in place of the PHP code contained in the original file. If you replace all these calls to the database with the relevant actual information you will save yourself a lot of unnecessary overhead. The effect on the speed of the pages will be quite substantial.

In your footer.php file you will most likely find similar database calls that could be replaced with the actual information.

The index.php file also has many of these but here I will stay away if you do not really know PHP. Many of the calls in this file are necessary and cannot be replaced.

Why not take a few minutes and turbo-charge you WordPress blog?

Similar Posts

Let's be sociable, come on, you know you want to. I appreciate the support.

  • Subscribe to feed
  • Favorite on Technorati
  • Submit to StumbleUpon
  • TwitThis

Post Title: Speeding up that WordPress blog
Author: Lyndi
Posted: 6th May 2008
Filed As: WordPress
Tags:
You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

11 Opinions have been expressed on “Speeding up that WordPress blog”. What is your opinion?
  1. Nishadha says:

    Thank you for this great information , I was looking for some ways to speed things up :)

  2. sailor says:

    Pleasure. There are quite a few ways of speeding up WordPress that I will still get to. In the mean time maybe you could do some Googling. Depending on what you have on your site, WordPress often does need quite a bit of speeding up.

  3. Jim Sefton says:

    Great post. Working with n-tier environments on a daily basis this is very obvious to me, but for some reason I had never thought about it in wordpress before. It is such a fundamental saving on the processing required to display the page I am kicking myself for not thinking of it before.

    Kudos for a great post!

    Jim

    Jim Seftons last blog post..Thermometer goals chart – FREE

  4. sailor says:

    Thanks for the nice comment Jim, I am glad it helped. Thanks a ton for the Stumble.

  5. Jim Sefton says:

    No probs… by the way, I noticed the no nofollow in the first instance by the logo appearing in the comments box. Is that soething you developed yourself or is there a plugin for it?

    Keep up the good work!

    Jim

    Jim Seftons last blog post..Wordpress 2.6 is out

  6. sailor says:

    Jim, I simply added the logo to the background of the textarea in the CSS. As soon as the box gets the focus it automatically disappears. Thanks for coming by.

  7. Jim Sefton says:

    Excellent, thanks. I have implemented it on my site and posted about it. I used the same graphic as you, is that ok? I wasn’t sure if it was one of your own or one produced for “the cause”. If you prefer I am happy to design my own, I just thought yours looks great.

    Jim Seftons last blog post..You Comment, I Follow (what does it mean?)

  8. sailor says:

    Jim, the logo was designed by BioTecK. I use it with kind permission from these guys. Pay them a visit, I am sure they will not mind at all.

  9. Icon says:

    Nice info, Sailor.
    I will try to apply this patch to my wp blog. I hope it will speed up a bit.
    Thanks.

Trackbacks/Pingbacks
  1. [...] The first post describes some tweaks that you can do to speed up your Wordpress blog. Wordpress themes are written in a general way to so it can be used by multiple blogs. This general style of coding increase the number of database calls and you can tweak your Wordpress theme to reduce the number of calls thus making it faster.You can learn a lot with examples by visting how to speed up your Wordpress theme. [...]

  2. [...] happened upon a great post by Sailor at Nice2all.com about speeding up Wordpress the other day. As I always like to do when I find something good, I [...]