Live data from Hacker News

Why you should choose HTMX for your next web-based side project (2024)

hamy.xyz

31–40 of 81 posts

Re: Why you should choose HTMX for your next web-based side project (2024)

#31
post #18

HTMX sets up an underlying network traffic pattern: 1. The user interacts with the page. 2. The page sends a request to the server. 3. The server returns one response to the client, containing HTML, which the client inserts into the page. 4. (Optional) If the response includes references to other resources, like images or fonts, the client makes more requests for these. The consequence of the 'one request, one respon…

Is it basically like Ajax?

Re: Why you should choose HTMX for your next web-based side project (2024)

#32
post #30
post #23

Earlier quoted context omitted.

Htmx can scale. It's very basic and Htmx isn't the only technology to use that approach.

It cannot scale because it doesn't have a solution for reusable components. That's why I have abandoned it. Frameworks like React solve this in a much saner way.

Reusable components are prerogative of the templating system, such as React, or Vue, or server side templates that the framework of your choice uses. Htmx works with already rendered HTML fragments from the back end and doesn't do templating on its own, so there's simply no room for it to "solve" reusable components

Re: Why you should choose HTMX for your next web-based side project (2024)

#33
post #31
post #18

HTMX sets up an underlying network traffic pattern: 1. The user interacts with the page. 2. The page sends a request to the server. 3. The server returns one response to the client, containing HTML, which the client inserts into the page. 4. (Optional) If the response includes references to other resources, like images or fonts, the client makes more requests for these. The consequence of the 'one request, one respon…

Is it basically like Ajax?

Yeah it's exactly AJAX. Except instead of writing Javascript to send requests and insert the response into the document, you use declarative HTML attributes to describe what you want to happen.

Re: Why you should choose HTMX for your next web-based side project (2024)

#34
post #31
post #18

HTMX sets up an underlying network traffic pattern: 1. The user interacts with the page. 2. The page sends a request to the server. 3. The server returns one response to the client, containing HTML, which the client inserts into the page. 4. (Optional) If the response includes references to other resources, like images or fonts, the client makes more requests for these. The consequence of the 'one request, one respon…

Is it basically like Ajax?

Yes. The cycle has completed and the old new things are new again. But they're still too new and unproven for the React-embroiled companies to switch just yet.

HTMX is basically a framework for AJAX that lets you more quickly set up interactions in the markup instead of having to write scripts to manipulate the DOM yourself. It also tells on sending HTML fragments over the asynchronous request instead of JSON that has to be "rendered."

Re: Why you should choose HTMX for your next web-based side project (2024)

#35
post #30

Earlier quoted context omitted.

It cannot scale because it doesn't have a solution for reusable components. That's why I have abandoned it. Frameworks like React solve this in a much saner way.

Reusable components are prerogative of the templating system, such as React, or Vue, or server side templates that the framework of your choice uses. Htmx works with already rendered HTML fragments from the back end and doesn't do templating on its own, so there's simply no room for it to "solve" reusable components

well now we got Web Components baked in. People don't want to give up React cause it is where many paying job is coming from.

It is the age old problem between better tech or better pay? What is even worse younger dev come in wanting to learn React cause it is the one that most job post is looking for. We end up negative economic to tech quality.

Re: Why you should choose HTMX for your next web-based side project (2024)

#36
post #20

I recently found Datastar [0], another hypermedia project. It was originally inspired by htmx, but they are fully on their own (hypermedia) course. According to the devs, who had a bunch of discussions with maintainers of htmx, the htmx project considers itself finished and no new features forthcoming. It is laudible, a project considering itself complete. Datastar considers its library v1.0 release [1] to be complet…

By the time they posted that they were deprecated and everyone is now on jQuery.

Re: Why you should choose HTMX for your next web-based side project (2024)

#37
post #11

Earlier quoted context omitted.

They didn't mention sending JSON though... and you can absolutely return HTML fragments in a JSON response.

But why?

Fetching data from APIs I have no control over, or ones that serve multiple purposes and use a single response format

Re: Why you should choose HTMX for your next web-based side project (2024)

#38

Earlier quoted context omitted.

They didn't mention sending JSON though... and you can absolutely return HTML fragments in a JSON response.

Then what's the point of using HTMX? If you're not sending just exactly the necessary HTML to replace the target's HTML; if you need to parse JSON, then even jQuery would be better suited. The whole idea of HTMX is to get rid of the extra steps.

I don't always have control over the remote end or due to business reasons the format can't be changed.

And since htmx also has template plugins, being able to feed JSON values into it makes sense to me... a similar project, EHTML has this feature.

Re: Why you should choose HTMX for your next web-based side project (2024)

#39
post #31

Earlier quoted context omitted.

Is it basically like Ajax?

Yes. The cycle has completed and the old new things are new again. But they're still too new and unproven for the React-embroiled companies to switch just yet. HTMX is basically a framework for AJAX that lets you more quickly set up interactions in the markup instead of having to write scripts to manipulate the DOM yourself. It also tells on sending HTML fragments over the asynchronous request instead of JSON that ha…

> But they're still too new and unproven for the React-embroiled companies to switch just yet.

I've seen a few of HTMX projects attempted in production, at my previous employer. Decently sized, moderately complex web products for serious commercial purposes

I will say though, all three were complete disasters.

Re: Why you should choose HTMX for your next web-based side project (2024)

#40

Considering most of my side projects are web based and I loathe JS and prefer MPA patterns, this is very intriguing. I admit I haven’t been keeping up with HTMX or new web frameworks. Anyone have any examples that are noteworthy?

As I mentioned in a comment above, I've seen a few commercial projects attempted. But I'm hesitant to recommend HTMX, all three of them were failures (and for technical reasons not business ones)
Post reply on HN