Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

201–210 of 458 posts

Re: Gov.uk drops jQuery from their front end

#201

Earlier quoted context omitted.

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.

I fail to see how replacing 1 line of jQuery with 10 lines of plain js is simple. Sure, you don't use those 10 lines all over the place, you write a function ... but then aren't you just recreating jQuery?

Yes but only the parts you need, which means better performance and job security.

Re: Gov.uk drops jQuery from their front end

#202
post #188
post #173

Earlier quoted context omitted.

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

Thank you for the feedback as well :)

> I'm better than most reading poorer copy but I consider your(unchanged) copy very good.

This is nice to hear/read, yet I'm a perfectionist who knows perfection do not exist. The pitch can always be improved and clarity/transparency is very important to us.

> Unfortunately without the words"audit", "WORM" and"incident search" present or prominent I'm not your market.

This proves my previous point, since we rely on Docker images to implement the monitoring/reactivity part, literally ANY workflow/business logic can be applied (but we've been told that it's hard to trust "it can do everything").

> But I could think of many thousands of publication sites longing for your tool, if those terms applied.

I'd love to get in touch with you about that, if you have time, you can find my contact info in my profile: https://news.ycombinator.com/user?id=linkdd

Re: Gov.uk drops jQuery from their front end

#205
post #71

Earlier quoted context omitted.

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 })

alternatively, if you need to use anything other than `forEach` for working on the list, you can turn the NodeList into an array using the array spread syntax (equivalent to using Array.from) e.g. [...document.querySelectorAll('a')] .filter(node => node.getAttribute("data-foo") === "bar")

Not everyone wants to be so wasteful.

Re: Gov.uk drops jQuery from their front end

#206

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 rather not write 10 lines of Vanilla JS when I can write a line using jQuery. And I do prefer jQuery-style syntax for manipulating the DOM.

Re: Gov.uk drops jQuery from their front end

#207

Earlier quoted context omitted.

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.

When jQuery was in its prime, stubbornella was a fixture of youtube playlists. One of the feathers in her cap was cutting yahoo's CSS in half, which resonated with a lot of us. CSS has been problematic for a long time.

I used to hate code generators because the code quality was always so bad that if a midlevel or senior dev was writing code like that I'd be talking to our manager about firing them, and for a junior dev we'd be talking about more intensive mentoring or even a PIP.

Once Sass introduced SCSS, that was the first code generator I ever met that actually impressed me, and Less is very close. The default CSS out of it looked very much like the sort of CSS you would expect from a project after someone had already gone through and cleaned up all of the cliched failure modes for medium sized projects. It felt like having a fast forward button. Still one of the fastest 'sells' for me, and I do quite a lot of technology selection for projects.

Not that it's perfect. Poorly written mixins/functions can generate way more CSS per call than is necessary, and I have a team of overbooked people that I need to sell on prioritizing fixing this sort of thing and I just can't find the bandwidth because there are always 2 more pressing issues I need to talk to them about. I can't squeeze blood from stone, and I can only ask for personal favors about as frequently as I can grant them, modulo any turnover - which has become a problem. Turns out if I take a shine to you, you're also really easy to hire somewhere else.

Re: Gov.uk drops jQuery from their front end

#208

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.

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

Re: Gov.uk drops jQuery from their front end

#209
post #205

Earlier quoted context omitted.

alternatively, if you need to use anything other than `forEach` for working on the list, you can turn the NodeList into an array using the array spread syntax (equivalent to using Array.from) e.g. [...document.querySelectorAll('a')] .filter(node => node.getAttribute("data-foo") === "bar")

Not everyone wants to be so wasteful.

what do you mean by "wasteful"?

Re: Gov.uk drops jQuery from their front end

#210

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(); ?

To be fair with the comparison, we should add error handling for the jQuery example:

  $.getJSON('/my/url')
    .done(data => {
      // success
    })
    .fail((jqxhr, textStatus) => {
      if (textStatus === 'timeout') {
        // connection error
      } else {
        // HTTP status error
      }
    })
And also consider the Fetch API alternative:

  fetch('/my/url')
    .then(response => {
      if (!response.ok) {
        // HTTP status error
      }
      return response.json()
    })
    .then(data => {
      // success
    })
    .catch(error => {
      // connection error
    })
Post reply on HN