News for hackers. Stuff that matters.
Re:Gov.uk drops jQuery from their front end by spicybright on Thursday May 19, 2022 @10:09AM (#31434855)
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.

Maybe it's different now, but using a jQuery makes it more likely the code will cover cases like that.

Re:Gov.uk drops jQuery from their front end by onion2k on Thursday May 19, 2022 @10:26AM (#31435076)
I worry too about people not considering accessibility.

This isn't a complaint you can level at the gov.uk team. They're obsessed with accessibility. Gov.uk is probably the best example of a well-designed, well-built, completely accessible website on the whole internet.

Re:Gov.uk drops jQuery from their front end by spicybright on Thursday May 19, 2022 @10:33AM (#31435180)
I meant more for anyone building a website.
Re:Gov.uk drops jQuery from their front end by psnehanshu on Thursday May 19, 2022 @04:55PM (#31440044)
Whilst *.GOV.IN (India) is the worst.
Re:Gov.uk drops jQuery from their front end by chipsa on Thursday May 19, 2022 @10:23AM (#31435040)
Collapsible section? https://developer.mozilla.org/en-US/docs/Web/HTML/Element/de...

There's some CSS transition stuff you can add to that to make it lightly animated: https://css-tricks.com/how-to-animate-the-details-element/

Yeah, jQuery might make some things easier, but when possible, using native HTML elements makes things even easier,

Re:Gov.uk drops jQuery from their front end by nhinck on Thursday May 19, 2022 @10:50AM (#31435406)
Hmm, I would agree that you can do 95%+ of stuff jQuery used to be used for in vanilla js or html/css in a nicer way but animated collapsible divs still require a stupid amount of js to achieve.
Re:Gov.uk drops jQuery from their front end by iCarrot on Thursday May 19, 2022 @11:31AM (#31436011)
Animated collapsible div can be done with 0 line of JS.

https://code-boxx.com/expand-collapse-div-css-only/

Re:Gov.uk drops jQuery from their front end by nhinck on Friday May 20, 2022 @07:02AM (#31445722)
Uhh, did you check out how that actually functions? It looks like garbage.
Re:Gov.uk drops jQuery from their front end by ThunderSizzle on Friday May 20, 2022 @11:04AM (#31448444)
Agreed, this example looks like total shit.
Re:Gov.uk drops jQuery from their front end by Cthulhu_ on Thursday May 19, 2022 @10:23AM (#31435037)
In 2020, a collapsible section is a matter of adding / removing a classname and a CSS animation; there's a few ways to do so, using jQuery is one, but you don't need thousands of lines of a JS library (network bandwidth + JS interpretation) to achieve that.
Re:Gov.uk drops jQuery from their front end by have_faith on Thursday May 19, 2022 @10:52AM (#31435432)
Can CSS transitions and animations handle animating to auto height/widths yet?
Re:Gov.uk drops jQuery from their front end by d1sxeyes on Thursday May 19, 2022 @11:31AM (#31435997)
I don't think so. One trick I've used to good effect is setting an high max-height, then translating by 100% and removing pointer events.
Re:Gov.uk drops jQuery from their front end by flatcakes on Thursday May 19, 2022 @11:37AM (#31436095)
I feel like this solution feels subtly "wrong" if you're animating, because that high max height will be arbitrarily far away from where you'd normally want to animate to. Doubly so for easing out.
Re:Gov.uk drops jQuery from their front end by d1sxeyes on Thursday May 19, 2022 @12:00PM (#31436361)
Yeah it's a bit weird, but haven't found a better trick yet.
Re:Gov.uk drops jQuery from their front end by pacaro on Thursday May 19, 2022 @10:14AM (#31434921)
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 by mitchdoogle on Thursday May 19, 2022 @10:39AM (#31435256)
If you've been using jQuery for years, know it, and can write a good amount of code without looking at a reference, then by all means, keep using it. It's not going anywhere anytime soon.