Prototype Size Concerns

Thomas Herold asks about my Share This Plugin:

The prototype.js is about 56k in size. My concern is that this slows down the loading time of my site. Any comments about this?

Yep, comments I’ve got because this was a carefully considered decision. First, let’s look at the ways this isn’t as big a deal as it seems (What, 56k per page load!?!), then we’ll look at the reasons for using it.

There are a number of reasons why 56k in additional download isn’t as bad as it used to be. For one, folks are more frequently on faster internet connections these days. For another, browsers and web servers have pretty much gotten then whole “ya need this file?”, “nope, I’ve still got it from last time” two-step down pretty well these days – the file isn’t downloaded every time. Smart web masters will also set up their web servers to gzip plain text output to web browsers that can accept gzipped content – this is pretty much all desktop browsers these days. Gzipped, the 56k becomes a mere 12k, which is a lot less offensive.

So that covers the ways that the 56k shouldn’t be so scary, but that is really only half the story.

In the 2.1 release, WordPress will be including Prototype.js as part of the default distribution. This will likely be something that plugin developers will take advantage of, and it’s a smart move. It’s much better to have plugin developers using an included, popular library than have each plugin distributing their own library. Does this put Share This a bit ahead of the curve, sure. But it also makes it a good citizen and example for other plugins that are built with 2.1 in mind.

So yes, it’s a trade-off. I could have gotten the same functionality in fewer bytes by using a different library or custom code, etc. But with a 2.1 release looking like it’s right around the corner, it seemed like a better decision to use Prototype.