WordPress Users: How to Increase Functionality AND Speed Up Your Site

Are you a plugins addict? Don’t worry – it’s nothing to be ashamed of. We don’t judge here. As struggling plugin addicts ourselves, we understand your plight, and are here to help.

What if I were to tell you that you probably don’t need all of those plugins, and that you could decrease your site’s load time and lose no functionality? Or perhaps even increase functionality at no extra load time cost?

To good to be true? Read on.

WordPress Users: How to Increase Functionality AND Speed Up Your Site

Are you a plugins addict? Don’t worry – it’s nothing to be ashamed of. We don’t judge here. As struggling plugin addicts ourselves, we understand your plight, and are here to help.

What if I were to tell you that you probably don’t need all of those plugins, and that you could decrease your site’s load time and lose no functionality? Or perhaps even increase functionality at no extra load time cost?

To good to be true? Read on.

WordPress’ Achilles Heel

As I have mentioned previously, WordPress’ enormous success is down in no small part to its staggering extensibility. At the time of writing, there are nearly twenty thousand plugins available for download from WordPress.org, with more being added every single day. It is easy to skim over that number without giving it much thought, but if you consider for a moment how big a number twenty thousand really is, the potential power you have in your hands might begin to sink in.

But with great power comes great responsibility. Plugins can be a nightmare – with everything from poor support, to security weaknesses (I’m looking at you Tim Thumb), to nasty code bloat, all waiting to trip you up.

Trip Hazard

Don’t get me wrong – I love plugins – but you should be aware of the potential ramifications. For instance, a quick scan of your site with the Plugin Performance Profiler can reveal some pretty damning results in terms of how resource-intensive your plugins are.

The Alternative

Now let’s talk about code snippets, which are lightweight, transparent, and controllable.

For those of you who don’t know, code snippets are essentially “mini-plugins” that you place in your theme’s functions.php file. What you choose to do with your functions.php file is essentially limited only by your PHP programming abilities.

Let me make something straight – there is absolutely a time and a place for plugins. Advanced functionality and extensibility should be packaged in plugin form. But for relatively straightforward tweaks and tricks, code snippets are likely to be a far more sensible option. There are probably code snippets available right now that can replace one or more of the bloated and unnecessary plugins installed on your site.

How to Get Started with Code Snippets

Even if you are a complete PHP novice, your functions.php file is unlikely to intimidate you. You can access it via FTP (you will find it in your active theme’s directory) or via the WordPress file editor (“Appearance > Editor” in the sidebar). We recommend that you access the file via FTP, because if anything goes wrong, you can easily delete whatever addition you made that caused the issue.

In its simplest form, the functions.php file looks like this:

Functions.php

Yours may well have more in it, but the principle remains the same – just add code snippets to the bottom of the file. It really is that simple – you can have plugin-style extensibility without putting much of a strain on your load times.

What Can You Do with Code Snippets?

The sky really is the limit. There are an enormous number of resources out there dedicated to providing popular code snippets. Here are three top sites to get you started:

And below are a selection of popular code snippets to give you an idea of what is possible:

What Code Snippets Will YOU Use?

There is no doubting the usefulness of using code snippets in adding functionality to your site whilst keeping resources required to a minimum. If you have any favorite code snippets, or have recently found one that you particularly like, please share them with us in the comments section!

Creative Commons image courtesy of fudj

Tom Ewer

Tom Ewer is the founder of WordCandy.co. He has been a huge fan of WordPress since he first laid eyes on it, and has been writing educational and informative content for WordPress users since 2011. When he's not working, you're likely to find him outdoors somewhere – as far away from a screen as possible!

8 Comments

  1. info

    There is 3d way to manage your custom code:
    http://wordpress.org/plugins/code-snippets/
    With this plugin you keep your functions.php clean and your snippets well organised.

  2. Steven Noble

    I know this post is almost a year old by now but I came here from a Google search and noticed this article is completely wrong compared to recent findings (So hopefully my comment puts new users in the right direction). Recently many tests have been done in regards to plugins/functions.php and there is NO difference between the two and loading times. Some popular WordPress sites use upwards of 80-90 plugins and it has no effect on speed at all. They would only affect speed if they were badly written and it doesn’t matter if they’re a plugin or in functions.php badly written code will screw things up. Plugins also help keep things tidy and out of your functions.php so you don’t have to go digging through a thousand lines of code to remove one function. On another point if you wanted to change themes a few years down the line (Which everybody would), having the functions not related to the way the site looks (such as custom post types) in a plugin will also save you the pain of moving all the functions over to the new theme. Plugins can also help with debugging if something isn’t compatible, you can easily see what’s causing the problem by deactivating each plugin rather than editing a thousand lines of code!

    1. Tom Ewer

      Hey Steven,

      In my humble opinion this post is as valid as it ever was.

      Take for instance a plugin that offers up 5 different functions of which you only use one. Is it better for site speed to use the plugin or add a snippet of code to functions.php that creates that one used function?

      Or what about a plugin that is unnecessarily bloated.

      Plugins keeping things tidy is a good point but that is exactly what I suggested the use of Code Snippets to keep things in order.

      Cheers,

      Tom

      1. Steven Noble

        Hi Tom,

        As I said before it all depends on the code in use. If the plugin has 5 different functions it shouldn’t cause any issues if it’s well written. However I agree about unnecessarily bloated plugins. Developers should make sure any code is in top condition before releasing it to the wild.

        On a completely different point I wouldn’t recommend anyone without a decent knowledge of the functions.php to be fiddling around in there. For less technical people it would be better to put the code into a file and drop it in the plugins directory in case they screw up their site. I’ve ended up with the white screen of death a few times when I was first getting started with WordPress.

  3. hardy

    Hey great article….certainly useful…
    thanks alot TOM :)

  4. kevin chard

    Hi Tom, great article and thanks for listing my site as a resource for people.

    1. Tom Ewer

      No problem Kevin!

    2. belgrade_celt

      Tom is a great blogger! Thank you Tom!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>