Speeding up that WordPress blog

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?

These posts might be related:

  1. WordPress Security
  2. Developing your own WP theme - part 2
  3. WordPress security - yet another look
  4. Backing-up your WordPress blog
  5. WordPress Custom Fields with a Twist

11 Comments to “Speeding up that WordPress blog”