Do I still need to use jQuery?
jQuery makes it so easy to start making your website be interactive at the client side. It was easy to learn, powerful, and has a large audience around the world – so there’s ample of plugins to use.
But things have changed. Cross-browser support for many things - including ajax calls – has been dramatically improved. Transitions can (at times) be achieved using CSS transitions. Heck, cross-browser development is so much better now thanks to the demise (and yes I will totally ignore you now) IE 8, 9 and 10.
Do I still need jQuery?
From where I sit right now, my feeling is that it depends on the project.
Firstly, jQuery is about 30kb to add to a project. Not much, and light weight compared to some full frameworks (I’m looking at you, Angular 2), but still is an extra resource to load.
I’m really excited to start a new project using Bulma for the layout components, mixed with VueJS and Buefy – but I do think this is great for a web app type thing – such as the administration interfaces. It’s a formal look, clean and simple, but also (thanks to Buefy) includes a large number of useful-for-admin controls including neat modals, form controls, date pickers, notifications and so on.
Going down that path, I’d look at using vanilla JS outside of VueJS and Buefy. VueJS likes to be in control (hmm sounds like me) so adding jQuery is asking for trouble. Let VueJS look after the DOM. This will take a bit of learning, but will be a good outcome. Given the weight of VueJS and Buefy, the saving of jQuery’s 30kb is handy. And for an admin interface, where I’ve often used jQuery UI, that’s then a bigger saving too. And, c’mon, jQuery UI (even with 1.12) is a bit ugly on the modern web.
For that project: no, I do not need jQuery.
Then there are other projects that don’t need more complicated UI elements – where something like VueJS and Buefy are a bit of overkill.
Maybe it’s progressively enhancing a feature on a website – modals, ajax-based form validation, smooth scrolling effects, slideshows. Right now, I’d probably leap in and say “yes”. Even this site (at the time of writing) uses jQuery. Just because its what I know.
There are some great plugins I use – modal dialogs, date and time pickers – it just is so easy to use. I’ve also written a number of helper files in JS, that rely on jQuery, for things like ajax calls, creating dialogs, cleaning content before display, and so on.
But, frankly, all of this could be re-written without jQuery.
There’s nothing that jQuery gives me that can’t be achieved in vanilla JS. Sure, it’s only a 30kb saving, but that’s also one less call to make, one less dependency, one less consideration.
While doing some research for this post, I also found a simple library called micromodal that handles modals nicely – and has neat markup to boot. There are some issues on Github that may need reviewing, but shows that one of the jQuery libraries I rely on and love working with is actually not needed.
But it all comes down to ease of development, and ease of implementation.
Is 30kb, via a CDN, that much bloat, for the benefits of ease of development? Maybe. Maybe not. If it means something can be pumped out quickly, then that’s good.
But when I start using VueJS more, then no, jQuery will be shelved.
Given that will need some of my helpers written in vanilla JS, maybe now is the time to migrate them all away from jQuery. There’s no dire rush – but as things need tweaking or reworking, switching away from jQuery I think could be for the best. It’s one less dependency.