News for hackers. Stuff that matters.
Re:The Future of Htmx by gjsman-1000 on Monday January 06, 2025 @02:06PM (#42614133)
Notice how the “modern” is almost always more verbose than JQuery.

JQuery might as well be a shorthand JS library.

Re:The Future of Htmx by matharmin on Monday January 06, 2025 @02:19PM (#42614332)
I view JQuery as similar to C in some ways: It's been around forever, it's mature, and it works. It gives a good experience to get something up and running quickly: it's lightweight and simple.

But if you're working on bigger projects: It is possible, but have have to be very principled in how you use it, otherwise you're going to end up with either a massive spaghetti codebase and lots of edge cases in your app that breaks.

Alternatives like React and Rust may add more complexity upfront, but the improved structure and safety it gives has big benefits in all but the smallest projects.

Re:The Future of Htmx by peebeebee on Monday January 06, 2025 @02:28PM (#42614462)
Not so sure about that. You can easily write horrible code in React: Too complex, inefficient, and/or resource-intensive. If you don’t know the tools and have good theoretical programming knowledge, all code will be spaghetti code in the long run.
Re:The Future of Htmx by klabb3 on Monday January 06, 2025 @04:16PM (#42615950)
I'm no fan of React, but these aren’t equivalent. If you follow the rules, react (or any of its alternatives) will manage stateful changes like adding and removing components and event listeners. JQuery is more similar to doing manual memory management in C. It’s extremely easy to get it wrong and introduce leaks and other non-local errors.
Re:The Future of Htmx by bdougherty on Monday January 06, 2025 @04:40PM (#42616219)
React is also extremely easy to get it wrong.
Re:The Future of Htmx by klabb3 on Tuesday January 07, 2025 @05:35PM (#42628507)
Can you give an example? I mean I know you can shoot yourself in the foot with any UI framework, but jQuery has no way of managing state, everything just leaks by default. Unless they’ve added something.
Re:The Future of Htmx by The_Colonel on Monday January 06, 2025 @03:17PM (#42615179)
I don't disagree, but this is not relevant for the vanilla JS vs. jQuery discussion, since vanilla JS has exactly the same problems you mention as jQuery.
Re:The Future of Htmx by recursivedoubts on Monday January 06, 2025 @02:09PM (#42614172)
it's a good API! and consistent!
Re:The Future of Htmx by Bengalilol on Monday January 06, 2025 @04:58PM (#42616431)
Have a look at jQuery 'load' :

<https://github.com/jquery/jquery/blob/main/src/ajax/load.js>

Then at the vanilla JS 'load' :

  const response = await fetch('/path/to/template.html');
  const body = await response.text();
  document.querySelector('#some.selector').innerHTML = body;
IDK, all in all it is a proxy functions lib.