Live data from Hacker News

jQuery v4.0 Beta

blog.jquery.com

331–340 of 404 posts

Re: jQuery v4.0 Beta

#331
post #89

Earlier quoted context omitted.

This is incredible and such a great ad for jQuery. It's almost as if the creator(s) built that site ironically. So many examples are way clearer and easier in jQuery, like this one: JQUERY: $(el).toggle(); IE8+: function toggle(el) { if (el.style.display == 'none') { el.style.display = ''; } else { el.style.display = 'none'; } } Gotta love that "modern" triple attribute repetition. From: https://youmightnotneedjquery…

> Gotta love that "modern" triple attribute repetition. You can golf it down a bit: el.style.display=el.style.display == 'none' ? '' : 'none';

Of course. Because that's infinitely better than:

  $(el).toggle();

Re: jQuery v4.0 Beta

#332
post #311

Earlier quoted context omitted.

Also, jQuery is awesome. People have been in love with the overly complex and fancy javascript frameworks for the last 15 years or so. But jQuery doing dynamic binding to dynamically generated forms for some error states and maybe an ajax calls is literally all the javascript you need in 99% of web pages and the rest is overkill. The industry is going to move away from the complexities to React and towards more of th…

No, the "industry" is not going to move away from React (or Vue or Solid or Svelte), but idiots on HackerNews (and Reddit and Twitter and Mastodon, etc) might finally stop conflating web SITES and web APPS. One can dream.

Agreed...Another gripe... the amount of people on HN complaining that a web-app doesn't 'work without JS, when the number of user's who disable JS inside their browser is well under 1%. HN users don't even consider they are not in anyway typical web users.

Re: jQuery v4.0 Beta

#334
post #260

Earlier quoted context omitted.

JQUERY: await $.post({ url: '/my/url', data: data }).then(() => {}); VANILLA: await fetch('/my/url', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }).then(() => {}); I know which one I still prefer.

You dropped about 250000 characters from the first example. Of course if you load a bunch of code beforehand your code will be marginally better. The fact is that you probably don’t need to send JSON anymore because fetch accepts the whole form as an object: await fetch('/my/url', { method: 'POST', body: new FormData(form) })

> Of course if you load a bunch of code beforehand your code will be marginally better.

That's exactly the point though. We use jQuery because it has an incredible easy and consistent interface that makes writing for the web so much more enjoyable. Selectors, events, chaining,... are all just nicer to work with than the vanilla counterparts. Same goes for all libraries and frameworks. :)

BTW: Your example is sending a "multipart/form-data". Not all API's will understand this, and will need JSON anyway.

Re: jQuery v4.0 Beta

#335

For those of you who are curious what drives jQuery in 2024 and beyond, you need to remember that WordPress is still more than 1/3 of the web, and the majority of installations and so many plugins critically rely on jQuery. Yes, seriously. Any advances to removing deprecated APIs or functions are great. jQuery will probably be around dominantly on the web for years to come.

Also, jQuery is awesome. People have been in love with the overly complex and fancy javascript frameworks for the last 15 years or so. But jQuery doing dynamic binding to dynamically generated forms for some error states and maybe an ajax calls is literally all the javascript you need in 99% of web pages and the rest is overkill. The industry is going to move away from the complexities to React and towards more of th…

Unpoly too (very similar to htmx but the small difference makes it a lot more convenient I feel, I wonder why Unpoly isn't getting as much traction as htmx)

Re: jQuery v4.0 Beta

#336
post #41

I'm consistently surprised by the commenters on HN who seem to think jQuery is just a DOM selection library, when in fact it is a widely supported, incredibly stable tool set for (yes) DOM selection, but also attribute manipulation, Ajax requests, event handling, animation, and general utility functions. What's more, where there _is_ native functionality that replaces jQuery, the API is never as fluent. For work that…

A few years ago I dropped jQuery for plain vanilla js and I've never looked back. Native js has everything jQuery has, except for the pile of often poorly maintained half baked "plugins", that usually only do what they want to do and not much else. Yes, the vanilla selectors are more verbose, but any half decent code editor will make them just as fast to type. I don't mean to be penantic, but I don't really understan…

"I don't really understand why so many people still use jQuery at all."

Because it has a beautifully designed API. I don't directly use jQuery usually anymore. But I use the API in a basic DOM wrapper I've written. https://gist.github.com/pseudosavant/b86eedd9960ade958d49447...

Re: jQuery v4.0 Beta

#337
post #242

Earlier quoted context omitted.

The only buggy or insecure code is really from third party plugins and themes. Wordpress core has been rock solid. Ya you still need to setup caching and there’s some modifications to run it at scale but that’s all a solved problem thanks to the likes of Automattic and their VIP platform.

how much of that ⅓ of the internet is running third party plugins and themes on their WP installation?

How much of the rest of the web are using third party dependencies in their code?

We’ve built sites for a very large social media company where everything had to be audited before production including third party plugins. WP VIP has a list of plugins they’ve vetted and/or applied their own patches to secure.

Re: jQuery v4.0 Beta

#338
post #89
post #67

Earlier quoted context omitted.

One website that almost always gets mentioned when people talk about jQuery today is "You might not need jQuery" ( https://youmightnotneedjquery.com/ ). That site is the best ad for jQuery I've ever seen. For almost every task it describes, the jQuery code is shorter, cleaner, and more intuitive than the vanilla "modern" JS one. And that's after almost 20 years, and I don't know how many billions of dollars invested…

This is incredible and such a great ad for jQuery. It's almost as if the creator(s) built that site ironically. So many examples are way clearer and easier in jQuery, like this one: JQUERY: $(el).toggle(); IE8+: function toggle(el) { if (el.style.display == 'none') { el.style.display = ''; } else { el.style.display = 'none'; } } Gotta love that "modern" triple attribute repetition. From: https://youmightnotneedjquery…

Plus, the jQuery example also accepts any selector for `el`, including ones that select multiple elements.

The `toggle(el)` function only accepts a single element that you've already selected (e.g: via `document.getElementById("foo")`). You'd need to at least add a call to `querySelectorAll(...).foreach(toggle)`, if you wanted to preserve that piece functionality (which you admittedly don't always want).

Re: jQuery v4.0 Beta

#339

Earlier quoted context omitted.

jQuery is not awesome. It was awesome 15 years ago. Now it's completely outdated. It's very hard to reason about DOM that can be manually changed by any random piece of code. That's why declarative solutions like React/Vue/Svelte are so much better.

No, if you actually make modules with jQuery where it’s creating it’s own DOM tree, it’s no different from what React & Co are doing. Reasoning about the DOM structure has almost never been an issue in my almost 20 years of professionally doing this junk. The complexity has always been elsewhere.

And you're arguing the complexity that has to be somewhere should go in your custom built jQuery modules instead of components built with a well-known framework?

I spent years maintaining front-end code built by devs who believe their way of doing things was better than what's popular in the industry and I disagree about jQuery entirely.

jQuery is a low level tool and always ends up biting people as the project grows.

Re: jQuery v4.0 Beta

#340
post #291

Earlier quoted context omitted.

> Upgrading PHP version is even more painful, I've tried to do version updates, and was alway easier just to build a new server. I upgraded PHP 7.2 to 8.3 for a business client yesterday. It was a CentOS VM. It took maybe 5 commands, no server restart involved either. I could barely bill an hour and that is because I kept tail -f their logs to see if everything went smooth. And it did. How is that painful?

This is just intellectually dishonest. It completely depends on whether your libraries have breaking changes and how your app is structured. Many legacy projects use old versions of ORMs and frameworks that don't support PHP 8. So now you're also upgrading code igniter and you're looking at hundreds of files that call it's ORM

No. If we're talking about tech debt (that's not what parent was talking about by the way) then JS is a magnitude worse. Running old projects from JS ecosystem can require multiple miracles, not only code refactoring.

And your example, codeigniter, is one of the worst examples in PHP.

Not only it is a framework that has minor usage: https://trends.google.com/trends/explore?q=codeigniter,larav...

It is infamous for being hard to upgrade. No responsible PHP developer would start a complex project in it today.

A typical PHP project in the last years use either Laravel or Symfony.

Not to mention PHP has mature tooling to perform automated code upgrade between versions: https://github.com/rectorphp/rector

The project I mentioned was 4 years old and so far no code change was required between PHP 7.2 and PHP 8.3.

And again, my parent was clearly talking about server upgrade: "was alway easier just to build a new server".

And the change I had to do was not even multiple lines, it was a single line in a Dockerfile. I found the Pull Request and it was from 7.4 to 8.3:

https://i.imgur.com/MmemYSp.png

Post reply on HN