You all must know me by now. I am always nagging you about code efficiency, using minimum plugins and other improvement tactics. The past couple of days there has been some interesting conversation and feedback on Kim’s blog, on the post she made a few months back asking for plugin ideas for me to code. From there the idea for the YAFootnotes and My Tag Cloud plugins have been given plus some valuable feedback. Now, there is another conversation started from a user, Richard. My reply to all his valuable feedback would a) be too long for a comment and b) illustrates what i think might help some other people too. So, i decided to go on with this blog post. Enough with the chit chat, let’s see what he says.
I will take it one at a time. Essentially what he suggests is this:
On one of my sites, I realized I was loading different versions of jquery from different plugins on every page amounting to some 200kb of totally wasted overhead.
Here there was something even worst happening. The plugin authors were loading a jQuery copy of their own, a library that WordPress loads by default! He was absolutely right to be frustrated. So, by now you are totally seeing where he is coming from. But let me tell you, i think we need to take this a little deeper.
First of all, those 200Kb he is claiming to be loaded each time, although wasted most of the time, they are not loaded all the time! Yes, if you make 10 clicks on his site, from his homepage, to an article, to a page, to another article etc those 200Kb will be sent your way only once. And that is because all modern browsers know about caching. Before loading anything, they send to the web server what is called a “HEAD” command. Essentially, what they do is, they check out if the local copy they have has changed, if not, they won’t request it again. I agree that 200Kb are wasted but that’s a small price to pay having all this functionality added to your site (for free if i might add).
One more juicy part is the average blog user. Now, i know many of my readers are passionate bloggers that know little on coding. That is something that happens with most of the bloggers out there. Imagine having a blogger write a page and having to decide which scripts or styles should he load or not. He has absolutely no idea what a script is, let alone decide if he wants to load it or not. I know Richard is talking about a plugin here, which means that it won’t be for the average user, but there was also a talk about expanding the functionality over to WordPress itself. That, in my humble opinion, wouldn’t work.
As a plugin, it could be coded, but, i think wouldn’t save you from much trouble. And here is why. Here is a final point, my major point. In a few words, if you have plugins loading as much as 200Kb of extra scripts, you should really, and i mean really, consider if you need all those. My bet would be on the amount of the plugins rather than poor coding itself. Yes, they are poorly coded but, can you stop using any plugin? The delay won’t be on downloading those extra kilobytes, it will be on extra processing time the script will need to create it’s output. Even if it doesn’t need to do anything at all, just by stopping execution of the platform (in our case WordPress) and calling a plugin function is enough. I know you might think i am exaggerating at this point but, believe me, too many plugins can slow you down sufficiently enough to notice, even if they do absolutely nothing.
All in all, Richard has a strong point, poor coding should be avoided, but, user discretion is required too. Consider very well the fact of installing a plugin before you go on and do it. Just because it’s easy to do it, doesn’t mean it is recommended.
As for a response to my friend Richard, you have a point but coding a plugin and adding more burdain to your blog is not the option in my oppinion.