Live data from Hacker News

Gov.uk drops jQuery from their front end

web.dev

221–230 of 458 posts

Re: Gov.uk drops jQuery from their front end

#221
post #205

Earlier quoted context omitted.

Not everyone wants to be so wasteful.

what do you mean by "wasteful"?

Creating an array, populating it with however many elements just to be able to call some methods and destroying it immediately afterwards. And doing it all over the app, just because it's syntactically convenient. (all while you already have an iterable collection in the form of NodeList)

Re: Gov.uk drops jQuery from their front end

#222
post #164

Earlier quoted context omitted.

What? Web APIs are one of the most stable APIs in existence. "Don't break the web" is taken very seriously.

The context for this belief has only existed for about 10 years now.

The phrase "Don't break the web" is a bit newer, but it's basically the sentiment that lead to WHATWG forming 18 years ago, and one of the big defining goals of HTML5 was to set a foundation for expanding the web platform in a backwards-compatible way. HTML5 has been out for about as long as the invention of the web to HTML5.

Re: Gov.uk drops jQuery from their front end

#223

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…

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…

Yeah that's what I'm afraid of. IE 5.5 diverging from Netscape 4 again.

Are we really betting on Microsoft, Google, and Apple not getting into a feature fight again?

Re: Gov.uk drops jQuery from their front end

#224
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'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.

Re: Gov.uk drops jQuery from their front end

#225

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…

Not sure you read the submission, but the move away from jQuery was not to move to anything "virtual DOM"/React/similar but rather that the functions provided by jQuery now have vanilla/"native" alternatives.

/username checks out :)

Re: Gov.uk drops jQuery from their front end

#226

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.

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

Re: Gov.uk drops jQuery from their front end

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

Re: Gov.uk drops jQuery from their front end

#228

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.

Absolutely. I stopped using actual jQuery a while ago in favor of a light (78 loc) wrapper around the native DOM that mostly uses the jQuery API. jQuery has a really well thought out fluent API.

https://gist.github.com/pseudosavant/b86eedd9960ade958d49447...

Re: Gov.uk drops jQuery from their front end

#229
post #119
post #93

Earlier quoted context omitted.

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

You probably shouldn't be making that query, unless you're doing something specific like web scraping and don't have control over the content of the site.

you could be using it already w/jquery though and if you just switched to the native selector it would stop working everywhere but safari.

"#some_combo:has(option:selected[value=..]) + .." seems like a reasonable way to conditionally target something to me, is it terribly worse than some other way?

Re: Gov.uk drops jQuery from their front end

#230
post #226

Earlier quoted context omitted.

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.

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 element example:

jQuery API:

  const fooElement = $('')
DOM API:

  const fooElement = document.createElement('div');
  fooElement.classList.add('foo');
  fooElement.setAttribute('style', 'display: none');
I know which ones I'd rather write and read.
Post reply on HN