Blog: JS

Do I still need to use jQuery?

Published

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.

Blog

View all
JS

Integrating Tiny with Vue in a real world application

TinyMCE 5 has made the setup process more straightforward - and even easier with the Cloud version. And as there are so many JS frameworks out there, Tiny have...

Continue reading...

PHP

Extending the ItemHelper for Joomla

There are times in Joomla where you want a bit of control over your content at the template override level – such as showing the first X characters of a string. PHP...

Continue reading...

JS

How Tiny helps me deliver the best content authoring experience

At Joomla Day Australia 2019 in Brisbane, I spoke about how TinyMCE helps deliver the best content authoring experience. And for those who couldn’t make it on...

Continue reading...

Photo

How to show real-time highlights and shadows clipping in Photoshop

I’ve used Photoshop for years. Decades even. Yikes, showing age there. But for my photography, I tended to use Photoshop for specific things – such as cleaning...

Continue reading...

I am the Development Director (and co-owner) at Mity Digital, a Melbourne-based digital agency specialising in responsive web design, custom web development and graphic design.
Mity Digital