Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

211–220 of 458 posts

Re: Gov.uk drops jQuery from their front end

#211
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

[deleted]

Re: Gov.uk drops jQuery from their front end

#212

Earlier quoted context omitted.

As a counterpoint, I had a similar conversation with a report of mine about jQuery. He said it was not necessary and you could just use vanilla js. I said while yes that's true as a dev if I told you I needed you to implement a new payment provider for billing would you tightly and directly align with who we used or abstract it away via some wrapper so that if we ever had to change it wouldn't be difficult? Of course…

The problem is that most of the "abstractions" provided by jQuery are no longer abstractions and can frequently be replaced with simple alternatives that are directly provided by browser APIs that have extremely wide support. https://youmightnotneedjquery.com/ is a handy illustration of this.

That site was very helpful when it first came out, but now that most of us don't even need to support IE11 it's assumption that you at least want to support IE10 is very stale.

Re: Gov.uk drops jQuery from their front end

#213
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).

> jQuery was making up for browser API shortcomings While this is true, I can still code circles around frontend developers using vanilla JS. The decline of jQuery is mostly due to the rise of webapp frameworks like React and Vue. But if you are tasked with adding like, a button to a static webpage, jQuery is still the king.

>The decline of jQuery is mostly due to the rise of webapp frameworks like React and Vue.

Partly. Frameworks like Angular/React/Vue are a necessary byproduct of building and maintaining large codebases. But the fall of jQuery was largely a result of a more standards approach in mainstream browsers (said another way: deprecation of IE and not needing to work at maintaining consistent behavior across browsers), as well as adding traditional jQuery-like features to vanilla JS.

There really isn't a big use-case for jQuery anymore, although I will remember it fondly.

Re: Gov.uk drops jQuery from their front end

#214

What's more convenient $.getJSON('/my/url', function(data) { }); or var request = new XMLHttpRequest(); request.open('GET', '/my/url', true); request.onload = function() { if (this.status >= 200 && this.status } }; request.onerror = function() { // There was a connection error of some sort }; request.send(); ?

fetch('/my/url').then(response => response.json()).then(data => handle it)

Re: Gov.uk drops jQuery from their front end

#216
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.

Although writing jQuery is still shorter (And likely will forever be). Editor (like vscode) nowadays is much more smarter then the era.

A lot of API with long names is no longer a issue to type. You just mark the variable as a element. After that, autocomplete handles the rest for you. Shorten the gap with experience of using jQuery. If developer tools is still as dumb as that era. I would think the transition is impossible.

And there are also more frameworks to enhance experience of style modification or templating. Back to then, there are only some dumb template that do initial rendering. But framework these days also handles update for you. So you don't really need to modify it directly by yourself unless in some edge case.

Re: Gov.uk drops jQuery from their front end

#217
post #32

Earlier quoted context omitted.

It takes 1min to write a wrapper around that, though. Having said that, for the sake of 25kb - if you use more than a handful of features you might as well just include it.

That's the problem. It takes only 1 minute to write a wrapper, so you will write one, and I'll write one, and your dog will write one.

If that is literally the only wrapper you need, sure go ahead.

But most of the time, you find you need another wrapper, and then another, and the next thing you know you have most of jQuery, just not as uniform or as well tested.

I've seen this with database ORMs also.

Re: Gov.uk drops jQuery from their front end

#218

Earlier quoted context omitted.

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

Thanks to cache partitioning, this is no longer true. See, it turns out that by carefully leveraging cached retrieval of third party resources, scripts on two different domains can figure out if they are running in the same web browser, effectively pulling off browser fingerprinting. To stop this, modern browsers don’t share third party resource caches cross domain. So using a well known CDN no longer confers any ben…

LocalCDN is great for this! Avoids both the privacy concerns, plus makes things a bit speedier as everything is readily available locally already

Re: Gov.uk drops jQuery from their front end

#220
We don't know what else was done to the site while jQuery was removed.

I would assume that the British government had considerable resources to put on the rewrite so it's quite possible that the removal was part of a general site refresh.

Post reply on HN