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.
Gov.uk drops jQuery from their front end
21–30 of 458 posts
Re: Gov.uk drops jQuery from their front end
#22Earlier quoted context omitted.
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 benchmark…
Re: Gov.uk drops jQuery from their front end
#23Earlier 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.…
Re: Gov.uk drops jQuery from their front end
#24Earlier 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.…
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
#25Earlier 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.
Re: Gov.uk drops jQuery from their front end
#26Earlier 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) )
Re: Gov.uk drops jQuery from their front end
#27Re: Gov.uk drops jQuery from their front end
#28Eh. 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.
Re: Gov.uk drops jQuery from their front end
#29Earlier 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) )
document.addEventListener('click', function(e){ var t = e.target;
if(t.closest('.foo') && t.nodeName.toLowerCase() === 'button'){
e.preventDefault();
// do stuff here
}
else if(t.closest('.bar') && t.nodeName.toLowerCase() === 'a' && t.classList.contains('here')){
e.preventDefault();
// do smth else here
}
}, false);one listener to rule them all...?
elegant enough and once you get used to it...
.closest can be pollyfilled too..
Re: Gov.uk drops jQuery from their front end
#30Earlier 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) )
At the very least there are some jQuery alternatives that are modular, smaller, and have less backwards compatibility like iirc zepto.