Why do we use jQuery?
It's a common question these days: "why use jQuery"?
Reasons given to avoid it are:
- Large size
- Poor UI Library
- No class support
- No script loader
- None of this, none of that
- Moan moan moan
As far as file-size goes, I think the lack of modularity could be a real issue. If we were building a fast-as-lightning mobile app, I'd break it into parts. Or use something else. Ender, for example.
But for a reasonably-sized website, here's what we really want:
- Friendly, familiar API: CHECK
- Well tested, especially across older browsers: CHECK
- DOM lookup, traversal, manipulation: CHECK
- AJAX helpers: CHECK
- Custom events framework: CHECK
- A few simple animation effects, including a queue: CHECK
Ok cool, so jQuery is actually giving us a lot of stuff, and we can just build on top of it where we need to. I DON'T find that jQuery is providing lots of things that we're not using. Also, jQuery isn't dictating how we work with our own code - it just provides a toolset for DOM manipulation. That gives us a lot of flexibility to find our own style.
On top of this, at Twitter we add:
- Loadrunner - for script loading / dependency management
- Our custom component framework (Flight.js)
Here's a few things we WISH we had:
- HTML5 polyfill - for additional input controls
- All of DOJO's UI components, especially (personally) the datagrid
jQuery's plugins and UI components are the parts I avoid, but are also the parts we can build ourselves. I envy the DOJO UI, because as a user I find the controls to be useful and reliable, but i always find it very hard to work with them. Their API is awful. I'd love to see a full port to jQuery.
Ultimately, jQuery is actually a useful tool. Long may it continue to be so.
Thanks for reading! I guess you could now share this post on TikTok or something. That'd be cool.
Or if you had any comments, you could find me on Twitter.