News for hackers. Stuff that matters.
Re:jQuery 3.6.0 by muglug on Tuesday March 02, 2021 @02:27PM (#26319320)
I think a lot! For example, the new https://www.whitehouse.gov uses jQuery.

When you just want to add a small bit of interaction to a mostly-static site, jQuery can help.

There's a current trend to complicate things with a JAM stack that really don't need to be complicated.

I've seen people propose something like

    [NodeJS/Ruby/PHP backend] 
      -> GraphQL API 
      -> React Frontend 
      -> static html
Where really they could have just gone with

    [NodeJS/Ruby/PHP backend] 
      -> static html
Re:jQuery 3.6.0 by ognarb on Tuesday March 02, 2021 @02:39PM (#26319502)
I do think in some cases SPA make sense, but in many other cases just using a bit of jQuery/vanilla js to add a bit of interaction is enough. Server side rendering is way easier to do and is often faster to load for the client.
Re:jQuery 3.6.0 by dna_polymerase on Tuesday March 02, 2021 @03:08PM (#26319907)
SPA make sense whenever you want to write a proper application running in the browser. When you just want a website, stop the SPA madness.
Re:jQuery 3.6.0 by solraph on Tuesday March 02, 2021 @05:49PM (#26322220)
> When you just want to add a small bit of interaction to a mostly-static site, jQuery can help.

For very small amounts, perhaps, but honestly, even then I think it has limitations. As an anecdote, about six months ago, I needed to add a couple of dynamic forms to a static site. The forms were a simple contact us, and a mailing list sign up form, and only needed to handle the states of Open->Submitting->Thanks|Failed->Open, while preventing double submissions, etc.

I wrote the first one in jQuery (site was already using it due to the theming), and making sure handled all the various edge cases, and fixing one bug didn't cause another was far harder and time consuming than it should be.

Out of frustration, I wrote the other form in VueJS, and hacked the whole form in about an hour or two. My take away was that anything involving state in jQuery can get overly complicated very quickly.

Re:jQuery 3.6.0 by wishinghand on Tuesday March 02, 2021 @02:38PM (#26319493)
> When you just want to add a small bit of interaction to a mostly-static site

Then I'd reach for Alpine. Very lightweight, and I can use the fetch API instead of $.ajax.

Re:jQuery 3.6.0 by purple_ferret on Tuesday March 02, 2021 @03:00PM (#26319800)
Jquery has been around for 14 years. That framework..16 months.

You want to be as confident as possible you can bump to a new version on your old site in 4 years if you have to? Use Jquery.

Re:jQuery 3.6.0 by SamuelAdams on Tuesday March 02, 2021 @03:09PM (#26319929)
Plus it's easier to hire for. Chances are more developers have experience with JQuery than <new hot js library>.
Re:jQuery 3.6.0 by wishinghand on Tuesday March 02, 2021 @03:22PM (#26320096)
Or just fork Alpine and fix it. It’s javascript, not rocket science.
Re:jQuery 3.6.0 by makeworld on Tuesday March 02, 2021 @02:49PM (#26319639)
Perhaps even htmx?

https://htmx.org/

Re:jQuery 3.6.0 by iagovar on Tuesday March 02, 2021 @03:33PM (#26320241)
This looks very cool, thanks.
Re:jQuery 3.6.0 by ergo14 on Tuesday March 02, 2021 @02:50PM (#26319666)
or Lit-Element.
Re:jQuery 3.6.0 by moocowtruck on Tuesday March 02, 2021 @03:32PM (#26320234)
whitehouse.gov uses jquery because its wordpress
Re:jQuery 3.6.0 by kyriakos on Tuesday March 02, 2021 @02:29PM (#26319356)
To be fair the first case is only static for the initial load then becomes a single page application
Re:jQuery 3.6.0 by muglug on Tuesday March 02, 2021 @02:35PM (#26319448)
Yeah, but very few sites need to be SPAs. SPAs come with a tremendous amount of extra requirements that, over time, can mire projects in cruft.
Re:jQuery 3.6.0 by snemvalts on Tuesday March 02, 2021 @02:49PM (#26319646)
There's no need to complicate static sites with jQuery. All it does can be achieved with vanilla.
Re:jQuery 3.6.0 by cookingmyserver on Tuesday March 02, 2021 @03:02PM (#26319820)
Vanilla has always been able to do what jQuery can, otherwise jQuery wouldn't exist. It all depends on what your threshold for abstraction and verbosity is. That is going to depend on what you are doing and who you are.
Re:jQuery 3.6.0 by Turing_Machine on Tuesday March 02, 2021 @03:41PM (#26320351)
Exactly.

I mean, all you really need is a Turing Machine, but they're not very pleasant to program.

Same thing with vanilla JS and jQuery.

Re:jQuery 3.6.0 by colejohnson66 on Tuesday March 02, 2021 @03:21PM (#26320081)
> All it does can be achieved with vanilla.

Well, yes. Every JS library can be written in vanilla JS. The point of jQuery, React, etc. is to make it easier for the programmer to reason about what is going on while avoiding bugs.

Re:jQuery 3.6.0 by cphoover on Tuesday March 02, 2021 @02:54PM (#26319723)
I tend to agree, and unless you have to support like IE prior to IE9 it will probably easily support all of your target browsers.
Re:jQuery 3.6.0 by WhyCause on Tuesday March 02, 2021 @03:07PM (#26319888)
Promises aren't available in IE11, and as the last "true" IE, I imagine it'll be around a bit longer than it should be.

I recently had to rewrite a bunch of vanilla promise-based code to use jQuery promises once I realized IE11 didn't work.

Re:jQuery 3.6.0 by labster on Tuesday March 02, 2021 @03:10PM (#26319943)
As a competitive code golfer, I can confidently say that vanilla JS has never offered the raw performance of jQuery.