Speed up WordPress, and clean it up too!
Every once in a while people will ask me to fix their blog, because it’s either slow, or broken. When it’s not something to do with their WordPress hosting, (some hosts are just plain bad and slow), most of the time this is caused by either broken plugins, or broken themes. There are a few things I tend to do when I get to clean up stuff, and I though I’d list them for you.
Clean up your theme
First of all, what I do is make the header.php file do a lot less queries. Because themes have to be easy to spread, they have to get almost all the blog specific info from the database. That results in a lot of queries for stuff that you could just hardcode into the theme. Some examples, taken from the default kubrick theme:
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content=" <?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
Could just as well be:
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
You can also:
- make your stylesheet URL’s static
- make your pingback URL static
- make your feed URL’s static
- you can remove the blog’s WordPress version
- make your blog’s name and tagline / description static
Doing all that, you can remove 11 queries to the database, and this can highly speed up your theme.