Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

181–190 of 458 posts

Re: Gov.uk drops jQuery from their front end

#181
post #145

Earlier quoted context omitted.

I think the more direct comparison is document.querySelector('#element').style.display = 'none' That has the same ergonomics as the jQuery selector, and is just a bit longer. I feel like with editors that autocomplete, it's not enough of a difference to warrant the extra dependency.

>That has the same ergonomics as the jQuery selector Nitpick: This crashes if #element doesn't exist, while the jQuery one does not. Also, the jQuery selector is a tiny bit more powerful (:even, :odd). IMHO, jQuery is good for what it's built for - a nicer interface than vanilla - but the main use case is much less needed now that frameworks exist.

A but fugly, ?. helps - document.querySelector('#element')?.style?.SetPropery('display', 'none')

Re: Gov.uk drops jQuery from their front end

#184
post #27

Tangential, but sometimes I see people say that jQuery is dead/failed. While it's not as popular anymore, I think that's actually the perfect evolution for it. jQuery was making up for browser API shortcomings, and now many of those shortcomings have been addressed and been incorporated into browser APIs (not everything, but quite a bit).

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 that the improved vanilla js is now "satisficing" for more people. Their threshold of ergonomic usability has been achieved and they stop looking:

https://en.wikipedia.org/wiki/Satisficing

Re: Gov.uk drops jQuery from their front end

#185

This article says makes 2 competing claims A) jquery deals with inconsistent browser implementations, largely in older browsers B) replacing it with modern API calls made the website more usable for all users including those on older machines (and presumably OS’s) I don’t see how to square those.

"Older" in those lines isn't fungible. E.g. jQuery's older browser would be IE 9 while Gov.uk's older browser would be IE 11 (they do have limited support for back to 8 though but it's not expected to be matching).

Re: Gov.uk drops jQuery from their front end

#186

Earlier quoted context omitted.

Is it harder or just a bit longer-winded? E.g. i'm thinking this is the same behaviour document.getElementsByClassName('sth')[0]?.closest('ul');

That's not exactly the same, I don't think, because jQuery will give you all the `ul` that are closest to `.sth`, not just the first. You'd have to write a loop over the list returned from `document.getElementsByClassName('sth')` to get the same behaviour (because it doesn't look like the standardised `closest` works on lists.)

If i'm following right, i think this expression would match?

    Array.from(document.getElementsByClassName("sth")).map(e => e.closest("ul"))
The jQuery is definitely nicer to read than this though

Re: Gov.uk drops jQuery from their front end

#187

When I first started programming I was pretty lucky to get a job at a games company. My first lead was a veteran who had shipped a lot of AAA titles and he loved his war stories. He was personally interested in performance and he would often cite hardware timings for specific cpu instructions. One story he told a couple of times was about some grey beard who was before his time. The grey beard was once a legend in th…

I wish JS would get all the nice jQuery features, like all the css selectors jQuery has, like a nice feature would be when you retive an HtmlElementCollection to be able to apply some transformation to all elements without having to write a for, or make use Array.from and then use forEach. But I agree I would not use jQuery in new project and when possible I would replace jQuery in existing code too.

[deleted]

Re: Gov.uk drops jQuery from their front end

#188
post #173
post #166

Earlier quoted context omitted.

I checked out kubirds, and even though I'm probably somewhat in your target demographic, I noticed that I couldn't discover what kubirds does without watching a video. Even scrolling down, and through the website, I didn't really understand it, until you compared to Nagios, which I am familiar with. Hope you don't mind a little unsolicited feedback. The website does look super clean! I would love to read a paragraph…

Thank you a lot for the feedback! We'll definitely do something about it :)

It's only8 minutes since your responseso I'd just like to say that I almost immediately got the gist of your product before any changes. Long advertising experience means like a remedial English teacher I'm better than most reading poorer copy but I consider your(unchanged) copy very good. Unfortunately without the words"audit", "WORM" and"incident search" present or prominent I'm not your market. But I could think of many thousands of publication sites longing for your tool, if those terms applied.

Re: Gov.uk drops jQuery from their front end

#189

When I first started programming I was pretty lucky to get a job at a games company. My first lead was a veteran who had shipped a lot of AAA titles and he loved his war stories. He was personally interested in performance and he would often cite hardware timings for specific cpu instructions. One story he told a couple of times was about some grey beard who was before his time. The grey beard was once a legend in th…

I wish JS would get all the nice jQuery features, like all the css selectors jQuery has, like a nice feature would be when you retive an HtmlElementCollection to be able to apply some transformation to all elements without having to write a for, or make use Array.from and then use forEach. But I agree I would not use jQuery in new project and when possible I would replace jQuery in existing code too.

You can extend HtmlElementCollection prototype with any methods you like. (it's NodeList, btw, what's returned from querySelectorAll)

Re: Gov.uk drops jQuery from their front end

#190

The 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…

The main value I found with jQuery was that the more your CSS selectors and jQuery selectors diverged, the more it felt like you were doing the same work twice. Now I'm curious what the CSS looks like for devs who have only ever known VDOM frameworks. Regular CSS can be pretty bad, particularly on a mature project. Are we talking dumpster fire or three ring circus here?

I think the css quality of newer projects has significantly regressed.
Post reply on HN