4 Simple Ways To Speed Up WordPress

Some self-hosted WordPress sites tend to run slow, especially when you receive tons of heavy traffic every day. This may be a result of the amount of large files your site needs to load or inefficient coding. But there’s nothing worst than a slow site, so here are some quick tips on how to speed up your self-hosted WordPress site. These tips mostly apply to self-hosted WordPress site because if you’re site is hosted on WordPress.com, you’re already being taken care of.

1. Staying up to date with releases

Staying up to date with the latest version of WordPress is critical. In every update, there are usually a lot of performance enhancements. The developers at WordPress don’t release updates just for fun, but because they’ve upgrades or made something about WordPress better.

Same situation with WordPress plugins, stay up to date with the latest versions. It’s as important, and for the same reasons. WordPress plugin developers release new versions because they’ve modified the code in some way to make the plugin better. So keep up with the releases!

2. Disable or delete unused plugins

This is probably one of the biggest issues that causes WordPress sites to slow down. Depending on the plugin, they can have tons of scripts and code. So if you’re not using a plugin disable it and maybe even delete it. Decide which plugins are necessary for your site to run and then do-away with the ones that aren’t needed. It’s as simple as that.

3. Clean up your code

Since your code is what runs your site behind the scenes, optimizing it can do wonders for your load time. Below are some easy ways you clean up your code to load faster.

  • Decreasing Whitespace

    Whitespace refers to the spaces used in your code. Some coders, like myself, like to use a lot of whitespace (indented tabs, line breaks, etc.) for better readability and organization. But, decreasing whitespace will speed up your site’s load time by shaving off some extra bytes off the total size.

    An example of using some whitespace:

    .test {
    font-family: Georgia, Times, serif;
    font-size: 12px;
    color: #000000;
    }

    An example of minimized whitespace:

    .test {font-family: Georgia, serif; font-size: 12px; color: #000000;}

  • Using external scripts

    Instead of placing tons of code in your header.php file, use external scripts. This allows the browser to cache the script so it won’t have to read it for every other page.

    An example of using external scripts:

    <script type="text/javascript" src="example.js"></script>

  • Using shorthand CSS

    Using shorthand CSS is great for everyone. It’s great for you, your browser, and your site visitors. It allows for your CSS to be more concise, and it loads faster too!

    An example of using long ass regular CSS:

    .test {margin-top: 7px; margin-right: 1px; margin-bottom: 5px; margin-left: 3px;}

    An example of using shorthand CSS:

    .test {margin: 7px 1px 5px 3px;}

4. Minimize PHP and database queries

And most important of all, cutting down on PHP and database queries. Each time a page on your site loads, if your browser has to execute any PHP queries, it adds to the load time. If you replace the PHP queries with static HTML, every time a page loads, your browser just reads the HTML.

An example of lots of queries & requests:

<title><?php bloginfo(’name’); ?><?php bloginfo('description'); ?></title>

<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />

<script type="text/javascript" src="<?php bloginfo('template_url'); ?>/mootools.js"></script>

An example of minimized queries & requests:

<title>WPCandy - The Best of WordPress</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta name="generator" content="WordPress 2.3" />

<link rel="stylesheet" href="http://wpcandy.com/wp-content/themes/wpcandy/files/style.css" type="text/css" media="screen" />

<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="http://feeds.feedburner.com/wpcandy" />

<script type="text/javascript" src="http://wpcandy.com/wp-content/themes/wpcandy/files/mootools.js"></script>

101 Responses to “4 Simple Ways To Speed Up WordPress”

Hafiz Rahman
Posted on January 4th, 2008 at 6:32 pm

The last point is particularly helpful. Why I didn’t think about hardcoding certain obvious values before? Thanks for the info, gotta modify header.php :)

The title tag might need to stay dynamic, though. For single post and so forth.

Anyways, I was expecting to read something about using caching plugin, or even redirecting to a html version during extremely high traffic (like David Airey with one of his posts about the cracking), but then again the title of this post says “simple ways”. So it’s all good.

Cheers!

Thássius V.
Posted on January 4th, 2008 at 6:48 pm

Great tips. Talking about the first one, the new version of WordPress makes it even easier to have up to date plugins because it tells users when there are new versions of these plugins.

I recommend the plugin WordPress Automatic Upgrade, which makes the updating proccess as simple as pressing one button.

Thássius V.
Posted on January 4th, 2008 at 6:49 pm

I came up with a question… On my blog I have tons of plugins, but almost all of them are disabled. If I completely delete them from my Plugins folder, would it make any difference in the blog’s speed?

Nathan Chapman
Posted on January 4th, 2008 at 7:31 pm

About your example to remove whitespace from CSS code, you could download a version with white space to your computer, then upload a version without any whtiespace to your server.
Then, if you need to change soemthing you have the easy-to-read version on your local computer.
A good online service for formatting and removing whitespace is the CSS Formatter and Optimizer, an online tool.

Blogging Magazin
Posted on January 4th, 2008 at 7:32 pm

I guess another important tip is to enable WordPress cache. This is a great feature of the system and can speed up the site.

Hafiz Rahman
Posted on January 4th, 2008 at 10:11 pm

@ Thássius V. : Disabling alone should be enough to speed up WordPress. Deleting them will save you space, but won’t increase the speed anymore.

Bram
Posted on January 5th, 2008 at 8:01 am

Some of these things actually made sense to me!

Especially the queries etc, i didn’t think about that before!

Thássius V.
Posted on January 5th, 2008 at 9:44 am

Once I heard about a plugin called WP Super Cache. Somebody said it makes blog loading even faster than WP-Cache does. WPCandy could try it and tell its users the results.

Michael Castilla
Posted on January 5th, 2008 at 10:15 am

@Bram: Haha, yeah after doing some research, I learned a ton of stuff I hadn’t known before.

@Thássius: I think I’ll do that. I’ll go install it now and see what’s up. I know a friend who uses it for when he receives a lot of traffic and he says it helps a ton.

kahi
Posted on January 6th, 2008 at 11:38 am

I love when people write about things they know really well. But I don’t think this article is that case. Try to research, try to measure and you will get know that these advices have almost no influence on performance.

Michael Castilla
Posted on January 6th, 2008 at 12:15 pm

@Kahi: I did do my research and the things I listed here in this post is what I found as a result of my research.

kahi
Posted on January 6th, 2008 at 3:17 pm

@Michael Castilla: What do you mean by research? I speak about exactly expressable values. DB queries and generation times before all. Do you have some numbers?

bboywicked
Posted on January 6th, 2008 at 7:16 pm

I love this, very helpful! :D thank you so much for the tips and the great post. Keep it up!

Julian Johannesen
Posted on January 6th, 2008 at 9:20 pm

how much does decreasing whitespace in your css really speed things up? are we talking 1% faster? 10% faster?

Thássius V.
Posted on January 6th, 2008 at 11:07 pm

@Julian Johannesen: Depends on the situations. By decreasing whitespace in the CSS, it makes the file smaller and faster to be loaded by user. Using the CSS Formatter and Optimizer, I could make my CSS file 30% smaller.

hellyeahdude.com
Posted on January 8th, 2008 at 3:11 am

Thassius is correct Julian. Decreasing the file size will speed things up. Think about downloading a file, the smaller the file, the better chance you have of getting it right away. Faster someone can download, faster the browser can start decoding and translating the code.

But with modern-day browsers and internet speeds, it probably won’t matter too much. The good benefit of using single line CSS is the ability to go back and be able to read and fix much easier. It is much simpler to find the DIV ID’s as well as being much faster for hand coding out CSS. Single line CSS fan right hurr!

Jermayn Parker
Posted on January 8th, 2008 at 11:03 pm

Whats up Kahi’s bum???

I do agree that while this is a spot on article, something new could have been a better option (like the plugin Thássius V. suggested).

In saying that i do like the idea of cutting down the php querries in the header, boy does that not get messy at times??

kahi
Posted on January 9th, 2008 at 12:37 pm

@Jermayn Parker - it’s all about that listening to advices in this article is wasting of time withou any effect, sure probably except the “disable unused plugins” advice.

By the way, making header static (point 5) does not cause any queries-count decrease, it’s mistake, advicing based on guess.

Mosey
Posted on January 13th, 2008 at 11:05 am

The last point is a huge revelation for me, thanks! :D Never quite thought about that before. With regards to the CSS, does the short-hand form work for all browsers?

Michael Castilla
Posted on January 13th, 2008 at 12:56 pm

@Mosey: Haha no problem. And yes I’m pretty sure short-hand CSS works in all browsers, since it’s just leaving out spaces.

Destos
Posted on January 15th, 2008 at 1:54 pm

@kahi and @Michael
I believe kahi is correct on your last point and you might want to redact if before everyone start taking out that vital dynamic content from their headers. I am pretty sure Wordpress autoloads all those values from the database in one query and then just servers the values from php’s memory.

To test this you could use wordpress’s query number display code which i don’t know off the top of my head. And just check and see if the total amount of queries lessens.

Chris Thomson
Posted on January 21st, 2008 at 5:25 pm

Thanks for the helpful tips! Now I’ve gotta implement these…

Jeffro2pt0
Posted on January 22nd, 2008 at 3:04 am

Great tips. One of the easiest things you could do to speed up the loading of your site is to minimize or eliminate third party services/widgets from being used on your blog. If the 3rd party site is loading slow, it’s going to cause the blogs it’s displaying on to also load slowly. Whenever possible, substitute a thirdparty service/widget with a WordPress plugin. This helps keep things local to your blog.

fikirbozan
Posted on January 23rd, 2008 at 7:13 am

Thanx a lot. These are very useful. I will try!

Angel Romero
Posted on January 24th, 2008 at 1:54 pm

Very, very helpful article. I am about 4 months into the whole Wordpress movement and some of these seem obvious. However, I simply did not think about them being issues. Thanks a lot.

Peter
Posted on January 26th, 2008 at 6:21 am

Interesting article :

http://aciddrop.com/2008/01/21/boost-your-website-load-time-with-3-lines-of-code/

Please read through the comments for WP related issues and follow-up in new releases of the script ( 0.3.1 at the time of writing )

More thoughts on this issue ( read the comments as well please )

http://paulstamatiou.com/2006/06/22/5-ways-to-speed-up-your-site

Max R
Posted on February 20th, 2008 at 10:02 am

Some observations:

The thing about removing queries and other PHP stuff: not every one has the same impact. WP actually tries to cache lots of stuff in memory, so that even when you place several functions that’d normally require a trip to the database get pulled from cache instead. That way, instead of the overhead of a database query, you only have the (much smaller, IMO mostly negligible overhead of a PHP function.

There’s a very small overhead in using php functions (in general) vs just putting in some static html. It’s there, but it’s small. You should consider each case separately to see if the speed benefit outweighs the convenience of keeping things dynamic.

Compressing CSS, JS and even HTML are not only interesting from a visitor bandwidth viewpoint (even though there’s still folks that don’t have 20Mbit connections at their disposal, don’t disregard them!), there’s also your own bandwidth to consider, especially if you get the occasional traffic spike. Also, minimizing the amount of stuff that gets called from your page (CSS files, JS files, images, etc): the visitor’s browser will open up a new connection for every single one, slowing things down. Don’t just minimize connections to other sites, keep an eye on connections to your own site as well. One big issue is that lots of WP plugins come with their own versions of prototype.js and the like, while there’s a version included with WP itself — so in the end you’ll end up with three different versions of prototype.js being included on your page. Bah.

Here’s a great tool to test the impact of making your code smaller and less dependant on external stuff.

I like your article, but there’s so much more to discover when it comes to getting your sites smaller and faster. Initially, that’s all I wanted to say. Sorry about going on and on. =]

Geek Mother
Posted on February 28th, 2008 at 9:15 am

I heard that one plugin in particular could really slow down your blog is Text Control ( http://dev.wp-plugins.org/file/text-control/trunk/text-control.zip?format=raw)

Can anyone verify that?

Sumesh
Posted on April 29th, 2008 at 12:16 am

Going with #2, also clear out database tables created by plugins.

Instead of writing CSS without any whitespace (which makes it unreadable, a better idea is to write CSS in the normal way and compress it with CSSClean (don’t be too aggressive on compression lest it strips out necessary rules). [oh wait, I just noticed it has been told by someone else. Oh well!]

The PHP engine is infinitely faster than MySQL, so the only thing of concern is database queries. However, in case of traffic spike, PHP can be a bottleneck too.

Web Hosting Sri Lanka
Posted on May 9th, 2008 at 4:58 am

Cool info. Thanks for sharing.

David
Posted on May 19th, 2008 at 6:58 pm

Good tips. I think these are all great. However for those that want to improve speed and performance in a matter of a seconds, I recently had a great experience with the plugin wp-supercache. Made a huge improvement on Wordpress improvement. For those interested, you can read about my suggestion for speeding up Wordpress performance.

http://www.widecastmarketing.com/wordpress-tips/speed-up-wordpress-performance.html

shelby wallace
Posted on June 17th, 2008 at 5:33 pm

I have been debating whether to use the WP Super Cache plugin. The issue I have is that I do not like the fact that you have to CHMOD 777 the Wp-Content directory. If I change it back after installation, it just seems to slow back down.

Someone needs to come out with a plugin to speed up wordpress like the super cache plugin without having to use 777.

Maybe someone already has one and I am missing it?

Another question I have is, which plugins and widgets are the worst as far as slowing down the loading of pages and posts?

Thanks for the tips and information.

I am still learning.

xiaomo
Posted on June 19th, 2008 at 3:58 am

thank you!

George (McHow2)
Posted on July 8th, 2008 at 3:05 am

This article deserved some link love. Very useful and easy to follow. So i decided to add your article to my blogroll at http://makehowto.info/
I wish you a lot of traffic and hopefully many WordPress Bloggers to make use of this. I’d love a faster Internet :-) Well Done!

dennis
Posted on July 9th, 2008 at 2:01 am

I’m not sure how much the white space deletion would help. We are talking milliseconds here and sometimes the code is hard to read after you one line it.

It just depends on your coding style. If you have to learn a new coding style is it really worth a few milliseconds?

Joe
Posted on August 15th, 2008 at 10:48 pm

I just did a css file cleanup test on http://www.cleancss.com/

It has some neat options too, as to how you would like it optimized. If it takes you 5 minutes to go back in and find where you have to make changes to your styles it may not be worth it though :-)

A.M.
Posted on August 18th, 2008 at 9:34 am

nice article, must to try :)

Make wordpress fly | www.redips.net
Posted on August 29th, 2008 at 3:23 am

If you want WordPress speed-up, you will have to consider WP-Cache also. WP-Cache is caching module and I made some test on WordPress installation before and after WP-Cache. Results were amazing. From 3.44 requests per second, WordPress became able to handle 235 requests per second, Testing environment was 2.6Ghz dual core P4 with 1GB memory on Linux.

Trackbacks
Leave a Reply