Earlier quoted context omitted.
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) )
Is it worth adding the library (download size + script parsing & execution) for that though? At the very least there are some jQuery alternatives that are modular, smaller, and have less backwards compatibility like iirc zepto.
Gov.uk drops jQuery from their front end
51–60 of 458 posts
Re: Gov.uk drops jQuery from their front end
#52Earlier quoted context omitted.
To add: jQuery is a pretty huge library for what it does. Talking both bundle size and execution speed. Not that the latter is noticeable for most cases, but it's still a cost. The question is: What for? The primary use case for it has been cross browser compatibility plus a bit of sugar. The former is _gone_ and the latter is easily replaced with a few lines of JS. Then there is an ecosystem of libraries and compone…
30kb minified and gzipped! Less than most hero images. It's a nice API for simple stuff. I think if you strip out the AJAX support it can get extremely tiny.
Re: Gov.uk drops jQuery from their front end
#53Eh. 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.
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 provides a clean API for manipulating the DOM, as this site demonstrates (which is ironic): https://youmightnotneedjquery.com/
Personally, for simple sites, I aim for vanilla JS but use jQuery (cash, actually) where it makes sense - such as working on collections of elements.
Re: Gov.uk drops jQuery from their front end
#54Earlier quoted context omitted.
For AJAX, jQuery is still simpler than vanilla JS.
Even fetch?
I think this really seems to stem from a "I'm only used to jQuery, anything else is a big mental effort to learn and I'd rather stick with what I know".
I get it. Vanilla JS, if you're not used to it, is scary. But if you're advocating for jQuery "for simple interactions", and assuming it's simpler than vanilla JS, at some point you should ask yourself if you're just letting your skills stagnate, and staying stuck in the past. You owe it to yourself to update your skillset. If you decide you still need jQuery (e.g. maybe you need a plugin/library that requires jQuery), then fine. But at least you'll be making an informed decision, not a FUD-driven one.
Re: Gov.uk drops jQuery from their front end
#55Re: Gov.uk drops jQuery from their front end
#56I still use jQuery for frontend JavaScript when I can. It's so much more efficient than native JavaScript. I can't imagine anyone prefers to write document.getElementById('element').style.display = 'none' rather than $('#element').hide();
Jr devs have the tendency then to discard jquery because "is old" not because it isn't working anymore.
Re: Gov.uk drops jQuery from their front end
#57The bashing of jQuery comes from junior devs. Of course a VDOM is clearer, more productive (and less performant) however most webapps with a minimum of logic have many legitimate uses of native dom/jquery in addition to the VDOM. And the interaction is perfectly safe as long as you do native DOM in the right lifecycle method (mounted). jQuery is a pleasure to use and give us a lot of power/expressivity. More generall…
Re: Gov.uk drops jQuery from their front end
#58The bashing of jQuery comes from junior devs. Of course a VDOM is clearer, more productive (and less performant) however most webapps with a minimum of logic have many legitimate uses of native dom/jquery in addition to the VDOM. And the interaction is perfectly safe as long as you do native DOM in the right lifecycle method (mounted). jQuery is a pleasure to use and give us a lot of power/expressivity. More generall…
Re: Gov.uk drops jQuery from their front end
#59The bashing of jQuery comes from junior devs. Of course a VDOM is clearer, more productive (and less performant) however most webapps with a minimum of logic have many legitimate uses of native dom/jquery in addition to the VDOM. And the interaction is perfectly safe as long as you do native DOM in the right lifecycle method (mounted). jQuery is a pleasure to use and give us a lot of power/expressivity. More generall…
Re: Gov.uk drops jQuery from their front end
#60Eh. 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.