Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

231–240 of 458 posts

Re: Gov.uk drops jQuery from their front end

#231
post #189

Earlier quoted context omitted.

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)

There is an issue you need to be aware , be careful if you hide the fact that this collection is "live". I mean this part from the docs

>An HTMLCollection in the HTML DOM is live; it is automatically updated when the underlying document is changed. For this reason it is a good idea to make a copy (eg. using Array.from) to iterate over if adding, moving, or removing nodes.

So you need something that will also be efficient and correct, not a 5 minutes implementation.

Re: Gov.uk drops jQuery from their front end

#232
post #208

Earlier quoted context omitted.

That's what everyone keeps missing. Can vanilla do what jQuery can? Of course, and that has always been true. What jQuery (and similar) offer is quality of life stuff, vanilla has never even tried to offer. This is still an ecosystem without a standard library and with no consistent design style/layout. It is janky and bad. It being "less bad than it used to be" isn't the shiny endorsement that everyone thinks it is.

jQuery is implemented in vanilla JS, thus logically all of it’s features can be done vanilla JS

That is generally true and not really specific to jquery

Re: Gov.uk drops jQuery from their front end

#233
post #226

Earlier quoted context omitted.

As somwone who constantly replaces jquey with vanilla js the difference is more like two lines of jquery against 3 lines of vannila js. One line more. But you have one dependency less, which is quite beneficial

Update: fixed formatting A lot of times the jQuery syntax is easier to understand (IMO). Remove element exmample: jQuery API: $('.element').remove() DOM API: document.querySelector('.element').parentNode.removeChild(document.querySelector('.element')) or if you want to introduce another variable just to remove the element: const child = document.querySelector('.element'); child.parentNode.removeChild(child); Create e…

HTMLElement.prototype.remove exists everywhere except IE:

https://developer.mozilla.org/en-US/docs/Web/API/Element/rem...

Also for element creation:

Object.assign(document.createElement("div"), { class: "foo", style: "display:none" });

I mean, you normally abstract these things with a helper fn or two, without importing the whole jQuery anyway.

Re: Gov.uk drops jQuery from their front end

#234

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…

> But to me, they are like the old grey beard who didn't update his knowledge as the times changed.

Maybe it's just me but with all the rampant age discrimination nowadays in tech, I really don't like to see the continued propagation of this stereotype.

All sorts of people of all ages are unwilling or unable to update their knowledge of new tech, there is no reason to link this characteristic to someones advanced age.

Re: Gov.uk drops jQuery from their front end

#235
post #152

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…

what's so wrong about sprinkling some jquery on a static website (generated with hugo or jekyll)? On https://kubirds.com I use: jQuery appear: https://plugins.jquery.com/appear/ jQuery fancybox: https://fancyapps.com/docs/ui/fancybox/ Do not put jQuery to the trash yet, it still have a long life ahead.

> what's so wrong about sprinkling some jquery on a static website

You're talking past one another. He's speaking in the context of AAA games, and the equivalent of that in the webdev world is a highly interactive application.

Re: Gov.uk drops jQuery from their front end

#236

I'm new to web-dev. Having read the vast majority of comments it seems some people think jQuery is unnecessary/obsolete. Others say it's API is better, more concise, more flexible, etc. As a newbie I decided to learn vanilla JS as I was too confused with the state of the various frameworks; I mean what one would you choose to start with? That said I'm interested in what jQuery can do that vanilla JS can't.

[deleted]

Re: Gov.uk drops jQuery from their front end

#237
post #208

Earlier quoted context omitted.

jQuery is implemented in vanilla JS, thus logically all of it’s features can be done vanilla JS

That's a bit like saying everyone should code in assembly. The argument isn't whether it's possible, but whether it's easier / more efficient.

I guess I should have added more meat to my comment:

It’s frustrating when people reject a good tool like jQuery, with the argument that the same functionality can be achieved with just vanilla JS.

Re: Gov.uk drops jQuery from their front end

#238

> It really begs the question: Do we really need Ergonomy today? That's a question that GOV.UK has answered with a resounding "no".

I don't know if you've ever used gov.uk, but I have literally no complaints about it (other than a few content-level ones, which the web design team can't help with). It's honestly a brilliant site.

Re: Gov.uk drops jQuery from their front end

#239

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 think you're greatly exaggerating the death of jQuery

> old trick's won't work

> writing is on the wall

jQuery still works and is used in an crazy amount of websites. It's not going away soon. The biggest downside is the extra network request, but it's probably cached in 99% of browsers, so all that's left is some extra CPU time.

You're also exaggerating the claims of jQuery defenders. No one here is arguing that the site should keep jQuery, or that you should write a ton of new jQuery code.

Re: Gov.uk drops jQuery from their front end

#240

Earlier quoted context omitted.

30kb gzipped is still 10x larger than Preact for reference

that doesn't make it an issue in any way, it's not a numbers competition unless you have a 56K

One of the explicit goals of gov.uk is to be maximally accessible, and that includes for people accessing the Internet on a potato or who have a metered connection.
Post reply on HN