Quantcast
Viewing all articles
Browse latest Browse all 12

Speeding things up

I decided to take a look at possible optimisations for this website, in order to make it load faster, and so on. I’d already done a bunch of this some time ago, but I rediscovered the Firebug plug-in for Firefox, and in particular its YSlow extension.

YSlow is a set of guidelines that Yahoo! published a while ago to help web-designers in their quest for the optimal code, and WordPress hasn’t ever been very YSlow-friendly.

So, what to do to clean things up?

The first step involved trying to see what I could change on my own (CSS & HTML validation, compressing CSS and Javascript files, removing unnecessary code, downloading & configuring the “Super Cache” plug-in, …). Fortunately for me, I’d already done that kind of stuff. So now I could sit back and rely on what others had found out!

After a few searches of the web, I stumbled upon this post, which happens to contain most of the information I needed to get this done.
Steps 2 to 4 were by far the most valuable to me, because I’d found similar results, but none that were this complete.

Next, I decided that the “WP-Polls” plug-in needed some work. I only downloaded and used that plug-in for a post concerning Google’s then-new favicon.
[For some reason, though, it seemed no longer to work (perhaps because of the latest version of WordPress, no idea) - this, however, has no bearing on the steps I shall now mention.]

See, many WordPress plug-ins that add features to posts are only used within posts, and sometimes, you really don’t need them on many posts. The solution was simple: change a few lines of code to make the plug-in only be active for these posts, i.e. make sure that the extra CSS/Javascript/… files aren’t called up for all the other posts & pages.

If you’re somewhat comfortable with code, here are a few steps you could follow:
- edit the main PHP file of the plug-in to add an action to “wp_extra” instead of “wp_head” (do a search for “wp_head” for that)
- edit the “wp-content/includes/general-template.php” file to add the following:

function wp_extra() {
do_action('wp_extra');
}

- add the following to the template’s “footer.php” file (with “postnumber” being the relevant post’s ID):

< ? php if (is_single('postnumber')) { ?>
< ? php wp_extra(); ?>
< ? php } ?>

(for some reason, I couldn’t post this as “< ? p h p" without the spaces, but just remove those two extra spaces per line)
If you want to do that for several posts, just change the "is_single('postnumber')" into "is_single(array('postnumber1', 'postnumber2', 'postnumber3'))" (and so on).

Theoretically, this should work. At least, it worked for me.

Feels snappier!


Viewing all articles
Browse latest Browse all 12

Trending Articles