Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

91–100 of 458 posts

Re: Gov.uk drops jQuery from their front end

#91
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 don't; it was an improvement when BackboneJS came out so I could reason about larger scale applications, and another improvement when AngularJS came out so I could build and write tests for logical, reusable components, and another when React (especially in 2022) was there and reduced these components to simple JS functions. That said, I don't like how complicated modern day front-end development is, to the point w…

Oh god, Backbone. I absolutely hated that framework. It didn't even seem to do anything, it seemed like I had to implement all of the logic myself. Except I had to do it their way, for some reason, and practically nothing made sense. (I haven't touched it in years, though, so my memory is probably distorting my experience)

I like the idea of React, just not what it has turned into. The amount of tooling that it has created to do things that should be simple (but aren't because of the runtime and/or the programmer), and the gymnastics it goes through so that people can have their precious (often unnecessary) SPAs, is ridiculous. That, and JSX continues to be an abomination that shits all over separation of concerns so that smoothbrains don't hurt themselves trying to reason over it.

Re: Gov.uk drops jQuery from their front end

#92

Earlier quoted context omitted.

By "more efficient" it seems like you mean "less typing" because that is significantly less efficient in terms of downloaded code size and performance (the jQuery code calls the vanilla code.) PS. $ is an alias for document.getElementById so you can just do $('my_id').style.display = 'none'.

most people probably have jquery cached in their browser if you're pulling it from the google cdn

That hasn't been the case for years because of per-origin caching. CDNs get their performance from edge routing, not caching.

Re: Gov.uk drops jQuery from their front end

#93
post #71
post #38

Javascript has become so nice, now that browsers support modules. I use a module "dqs.js" for all my query needs. It contains only these two lines: export const dqs = document.querySelector.bind(document); export const dqsA = document.querySelectorAll.bind(document); And use it like this: import { dqsA } from 'lib/dqs.js'; for (const rabbit of dqsA('#rabbits .green')) { ... do something with all green rabbits ... }

There is .forEach() on NodeLists, so you can do stuff like this in every browser, no lib, no helper functions needed: document.querySelectorAll('a').forEach(tag => { // operate on tag })

how's browser support for something like "a:has(img[src$='.gif'])" though?

Re: Gov.uk drops jQuery from their front end

#94
Most developers don't seem to understand that jQuery was not just a wrapper for browser compatability. Yes, we do have all that nice functionality in a modern browser nowadays but compared to jQuery it just not as elegant. jQuery still has a place.

Re: Gov.uk drops jQuery from their front end

#96
post #94

Most developers don't seem to understand that jQuery was not just a wrapper for browser compatability. Yes, we do have all that nice functionality in a modern browser nowadays but compared to jQuery it just not as elegant. jQuery still has a place.

And that place is? Not saying I disagree, this just feels like an incomplete thought.

Re: Gov.uk drops jQuery from their front end

#98

Earlier quoted context omitted.

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.

Can CSS transitions and animations handle animating to auto height/widths yet?

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

#99
post #47
post #24

Earlier quoted context omitted.

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,

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.

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

#100
post #89

Earlier quoted context omitted.

I really don't get this discourse, jQuery API is much more ergonomic, concise and clearer than the DOM api. Sure you can do it but that doesn't mean you should

I think it's a bit of both. jQuery served the purpose of making web development more sane back in the day by handling all browser quirks. Part of that was the nice syntax. I personally have tried to drop jQuery, but truthfully, its syntax is just much easier to use. Nowadays, I use Cash https://github.com/fabiospampinato/cash to give me the nice syntax without the bloat. It strikes the perfect balance for me.

I did a javascript project targeting web/blackberry and early ios. We used jQuery to smooth out the kinks (or that's what our lead told us). It worked as expected.

Went from disliking it to really liking the syntax. Its pretty clear and easy to use, which is why I still use it. We don't use it extensively becaue we're still on the "submit form, get page back with javascript graph and data tables table, development model. We probably should transition to a framework, but they evolve so quickly ...

Post reply on HN