Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

11–20 of 458 posts

Re: Gov.uk drops jQuery from their front end

#11
post #9
post #6

Earlier quoted context omitted.

For basic interaction, you don't need anything but vanilla JS. Browsers have come a long way since the days where jQuery was almost necessary to deal with all of the minor differences/bugs in various browsers.

It's a much nicer syntax and has a ton of useful helpers. Vanilla js for similar things just looks like someone has waved the ugly stick at it. There are sound arguments against jQuery but the "you can just use vanilla" is the least convincing.

Not having to load yet another JS library on your page if you don't really need it is a pretty good argument, I'd say.

Re: Gov.uk drops jQuery from their front end

#12
post #5

I miss the days when jQuery reigned supreme, and all the tenderfoot magpie developers didn't yet have the twinkle of React in their eyes

I remember doing pocs with observables, angular and react back when they were all way new and thinking observables really makes the other two unnecessary.

Re: Gov.uk drops jQuery from their front end

#13

Eh. Everyone hates on jQuery, but for most informational sites that's really all you need for basic interaction. Speed really isn't bad, and it's so straightforward that it's hard to mis-use at this point. I seem to have way more issues with newer frameworks/SPA if I'm not using chrome with no extensions. Makes me nervous dealing with important stuff like banking or government sites.

I loved jquery back in the day. It made web development bearable in a time when it was a clusterfuck. I think a lot of people owe a lot of thanks to jquery. But in 2022 vanilla javascript is all you really need.

jQuery still offers a much nicer experience. The built-in dom apis are neither very elegant nor ergonomic.

    // jquery
    $(selector).on('click', fn)
     
    // vanilla js
    document.querySelectorAll(selector).forEach(el => 
      el.addEventListener('click', fn)
    )

Re: Gov.uk drops jQuery from their front end

#14
We found it to be about 32kb gzip+minified in our builds. I just dropped it from one of our apps, where it wasn't even used except in a legacy logging module. We replaced the ajax call with XHR. The other app we maintain has it as well, again only for the ajax method.

While it may be nice, for large production apps we'll take the filesize gains where we can find them.

Re: Gov.uk drops jQuery from their front end

#15

Eh. Everyone hates on jQuery, but for most informational sites that's really all you need for basic interaction. Speed really isn't bad, and it's so straightforward that it's hard to mis-use at this point. I seem to have way more issues with newer frameworks/SPA if I'm not using chrome with no extensions. Makes me nervous dealing with important stuff like banking or government sites.

If you just want “basic interaction” without any framework complexity, alpine.js is way better than jquery. It’s extremely simple and does the basic data binding stuff that jquery lacks.

Re: Gov.uk drops jQuery from their front end

#16
post #6

Earlier quoted context omitted.

For basic interaction, you don't need anything but vanilla JS. Browsers have come a long way since the days where jQuery was almost necessary to deal with all of the minor differences/bugs in various browsers.

I'll admit I'm a bit out of practice with the state of vanilla JS, but it seems like you'll be re-inventing the wheel for simple stuff. Like a collapsible section that's lightly animated. I worry too about people not considering accessibility. A lot of my bugs day to day is not being able to tab into things like hover menus or being able to activate buttons because someone forgot to consider correct event callbacks.…

You bring up some interesting concerns. It's a good example of why there isn't a one size fits all answer. The UK gov site has high standards for these kind of things so will do it right anyway, but for a small shop leaning on a framework makes a lot of sense

Re: Gov.uk drops jQuery from their front end

#17
post #11
post #9

Earlier quoted context omitted.

It's a much nicer syntax and has a ton of useful helpers. Vanilla js for similar things just looks like someone has waved the ugly stick at it. There are sound arguments against jQuery but the "you can just use vanilla" is the least convincing.

Not having to load yet another JS library on your page if you don't really need it is a pretty good argument, I'd say.

OP's argument is that jQuery is all you need for basic use cases, so that'd be the only JS library loaded.

Re: Gov.uk drops jQuery from their front end

#19
post #11
post #9

Earlier quoted context omitted.

It's a much nicer syntax and has a ton of useful helpers. Vanilla js for similar things just looks like someone has waved the ugly stick at it. There are sound arguments against jQuery but the "you can just use vanilla" is the least convincing.

Not having to load yet another JS library on your page if you don't really need it is a pretty good argument, I'd say.

Except we've become so used to loading multiple megabytes of JS even on a simple blog post, that a 30KB library probably won't make a noticeable difference. Insofar as file size is concerned, I'd much rather pull in jQuery than some random npm package that depends on god-knows-how-many other random packages.

Even GOV.UK, an incredibly lean website by today's standards, only noticed a 10% difference in their benchmarks.

Re: Gov.uk drops jQuery from their front end

#20
post #13

Earlier quoted context omitted.

I loved jquery back in the day. It made web development bearable in a time when it was a clusterfuck. I think a lot of people owe a lot of thanks to jquery. But in 2022 vanilla javascript is all you really need.

jQuery still offers a much nicer experience. The built-in dom apis are neither very elegant nor ergonomic. // jquery $(selector).on('click', fn) // vanilla js document.querySelectorAll(selector).forEach(el => el.addEventListener('click', fn) )

It takes 1min to write a wrapper around that, though.

Having said that, for the sake of 25kb - if you use more than a handful of features you might as well just include it.

Post reply on HN