Tips For Dirty Bloggers Pt 2: Is Clean Code That Important?

Tips For Dirty Bloggers Pt 2: Is Clean Code That Important?

Clean Code

I could keep this article very short by simply saying “yes”.

…but that wouldn’t do you much good, would it? After all, if you spent all of your time simply following people’s advice on the internet without understanding the reasons why, you’d be doing an awful lot of crap.

Before I start, I should clarify that when I refer to “code”, I basically mean anything that relates to the back end of your blog. So code, images, and anything else that could be considered “back end” (oo er).

There are two main reasons why you should try and keep your WordPress blog’s code squeaky clean. Let’s discuss them.

1. Site Speed

Fast Dog
Whilst your site will obviously never be as fast as Blurdog, we can always dream...

This isn’t a glamorous topic, and as such, isn’t written about that much. After all, who wants to talk about something that you can’t actually see? Site speed has no chance up against such relatively exciting topics as design and content.

But regardless of that, site speed is incredibly important to the success of your blog. No doubt you have read countless times just how darned impatient us web folk are. Supposedly, you only have 7 seconds to convince someone that they should stick around when they first hit your blog. Now I don’t know how accurate that truly is, but the principle is certainly spot on. People will not be patient with your blog – they want to know what it can do for them, and they want to know quickly.

For argument’s sake, let’s assume that the “7 second rule” is correct. Now then, if your site takes 7 seconds to load, how much traffic do you think you are losing? Still think site speed is a boring topic? It can make a world of difference.

And trust me, a 7 second load time isn’t actually that unusual. All it takes is a load of bloat from large images, WordPress plugins and widgets, and poorly-coded themes. You’ll be kissing your visitors goodbye as they leave in frustration, whilst your blog chugs along like a Victorian-era steam train.

2. Google Love

Google Classic
Make sure that your blog isn't so slow that people think that they are actually using Google Classic!

Google is getting more sophisticated with every passing day. And if there is a factor that is relevant to users (oh say…site speed?), it won’t take long for Google to build it into its search algorithms. Back in April 2010, Google officially announced that it takes site speed into account when determining its rankings. So site speed is actually relevant before visitors even get to your site!

Now there are plenty of ways in which site speed can be affected, but the ‘cleanliness’ of your code is way up there. Whilst there is no doubting the power and all-round general awesomeness of the WordPress platform, its power does lend itself to (often inadvertent) abuse.

What Can Be Done?

Tee hee

I hope I now have you convinced that clean code directly correlates to (a) user engagement and (b) your blog’s Google rankings.

First of all, you need to figure out how fast (or slow) your page is. This won’t be measured in terms of “your site loads in X seconds”, as that depends on a huge number of variables, many of which are on the user’s side. Instead, you can download tools such as Page Speed (by Google) or Yahoo YSlow (by, erm, Yahoo). These handy little utilities will investigate your blog and break its performance down into various different categories, such as the number of external Javascript files you use, whether you resize images with HTML, and so on.

I know it all sounds very technical, but there should be at least a few points you can pick up on, regardless of your technical ability. And beyond that, the tools can also give you a better overall picture of how your site fares in terms of speed, which is definitely a good thing, regardless of how much you actually understand!

What Next?

If you have carried out some tests and find out that your blog is slower than a really, really slow sloth (and let’s face it, sloths are pretty damn slow to begin with), what is the next step?

Ultimately, you should aim for your blog to look as awesome as a sloth, but not be as slow.

There are a couple of great resources that can help you out. For the technically-minded, check out Yahoo’s Best Practices for Speeding Up Your Web Site. I’ll be honest, that one had my head spinning. A perhaps more user-friendly resource is The Webmaster’s Turbo Kit: 50-Plus Tips and Resources to Improve Your Site’s Speed and Performance. Absurdly long title aside, it is chock full of great advice for speeding your blog up.

What about WordPress specific advice? Well, there are four main things you can do to keep your WordPress blog running smoothly:

  1. Your theme: higher-end, premium themes tend to be better-designed and faster. In fact, some promote speed as a selling point.
  2. Plugins: more plugins = more code. Cut down on unnecessary plugins, and try not to use them whenever possible (i.e. if you can do it manually and with relative ease, ditch the plugin!)
  3. Images: make sure that they are the right size and are well-compressed before you upload them to your blog!
  4. Plugins: again? Yes! Download a caching plugin such as WP Super Cache or W3 Total Cache to boost your blog’s loading speed.

Over To You

What are your thoughts on clean code? Do you consider it important? How does your blog fare in terms of site speed? And do you have any awesome tips for turbo-boosting your WordPress blog? Let us know in the comments section!

Creative commons photos courtesy of Maria Cartas, dullhunk, Andrew MorrellNiels Heidenreich and Jesper Rønn-Jensen