Steve Workman's Blog

Going jQuery-free

Posted on by Steve Workman About 2 min reading time

It's 2014 and I'm feeling inspired to change my ways. In 2014, I want to go jQuery-free!

Before I get started, I want to clear the air and put in a big fat disclaimer about my opinions on jQuery. Here we go:

jQuery is an excellent library. It is the right answer for the vast majority of websites and developers and is still the best way to do cross-browser JavaScript. What I am against is the notion of that jQuery is the answer to all JavaScript problems.

Lovely, now that's done, this is why I want to do it. Firstly, as lots of people know, jQuery is quite a weighty library considering what it does. Coming in at 32KB for version 2.x and around 40KB for the IE-compatible (gzipped and minified), it's a significant chunk of page weight before you've even started using it. There are alternatives that support the majority of its functions in the same API, such as Zepto, but even that comes in at around 15KB for the most recent version, and can grow larger. The worst thing for me, is that I don't use half of the library, all I really do is select elements, use event handlers and delegation, show/hide things and change CSS classes. So, I want a library of utility functions that only does these things.

Word to the wise, this is not a new notion, and follows on very nicely from the work that Remy Sharp has done in this area in his min.js library.

I'm going to write a series of posts as I attempt to separate myself from jQuery, and make my websites leaner and faster. The first of which will be on "what you think you need, and what you actually need" and give you ways to work out if this approach is for you, or if you should be sticking with jQuery. Next, I'll cover the basics of what a minimalist jQuery library; and finally I'll cover strategies for dealing with unsupported browsers.

Let me know if there's anything in particular you want me to cover, and I'll do my best to go over it for you.