Live data from Hacker News

htmx

htmx.org

81–90 of 291 posts

Re: htmx

#81
post #10

How does htmx compare with alpinejs ( https://alpinejs.dev/ )?

HTMX and Alpine pair well together.

Generally, Alpine would handle pure client-side functionality, like toggling classes, expanding a drop-down multi-select, etc.

HTMX for server interactions, fetching, posting updates, etc.

One can accomplish a lot with little to no JS, with the app primarily driven by the backend. Which is quite a benefit if you know and like PHP/Python/Go/Elixir/C++ better than JS. Or just don’t like working in JS.

Re: htmx

#82

I continue to be impressed at the effort people will put into avoiding writing any JavaScript. Is it really easier to learn yet another DSL embedded in attribute tags rather than taking a day to setup your JS dev environment and then writing idiomatic code for running inside a web browser? Surely your htmx project will eventually cross a complexity threshold where you've added enough scaffolding that you may as well…

i will have you know that i wrote an awful lot of javascript to avoid writing javascript!

Re: htmx

#83

Earlier quoted context omitted.

I think you could expand your definition of small projects somewhat. I used to work at a marketing agency many years ago, there's a huge number of professional, revenue generating websites out there that just host a form. And that form probably just needs to send an email. Using a form, then a network request to some service, then showing some HTML will solve 100% of the problem for the local hair salon taking reserv…

> there's a huge number of professional, revenue generating websites out there that just host a form. And that form probably just needs to send an email. You don’t need JavaScript or htmx for this. It’s been in the html standard since 1.0. Forms work from plain vanilla html. > Using a form, then a network request to some service, then showing some HTML will solve 100% of the problem for the local hair salon taking re…

How do you make a request to a URL and then turn the response into HTML without JavaScript?

Re: htmx

#84

I continue to be impressed at the effort people will put into avoiding writing any JavaScript. Is it really easier to learn yet another DSL embedded in attribute tags rather than taking a day to setup your JS dev environment and then writing idiomatic code for running inside a web browser? Surely your htmx project will eventually cross a complexity threshold where you've added enough scaffolding that you may as well…

It's not that I avoid JavaScript, it's that I want my work to be accessible to someone without JS as a requirement, for whatever reason they may be in that state and configuration, whether by choice or not. I write plenty of JS (12% of my biggest project, according to GitHub), but it's added onto HTML in such a way that the HTML still works for: * a security-minded person who has it turned off in their browser, * a u…

I get what you're saying but I the context of the discussion, Htmx requires JavaScript, doesn't it?

Re: htmx

#85
post #25

Earlier quoted context omitted.

That makes no sense, HTML is by design not supposed to be dynamic, that's the point of JS. There's a nice, clean, separation of concerns with HTML, CSS, and JS. As an aside, htmx uses JS under the covers to make HTML dynamic.

> HTML is by design not supposed to be dynamic, that's the point of JS. You are putting far too much faith in the design of web standards. Anyways, here's a counterexample to your claim: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/di...

and are older examples.

And of course , , annnnnd cough .

There was and for some reason still if you wanna consider animations dynamic.

Re: htmx

#86

Earlier quoted context omitted.

The docs don't seem to suggest using it for non-trivial things without hyperscript. https://htmx.org/docs/ They do suggest being able to use it without learning a lot of hyperscript, but I see the same with Svelte, where you can get by on copying and pasting a great deal. https://learn.svelte.dev/

most of the examples don't have any hyperscript in them htmx generalizes HTML as a hypermedia, making any element a hypermedia control that can issue any type of HTTP request in response to any event and target any element in the DOM for replacement that's the concept, improve HTML, and it gives you quite a bit more than plain HTML, but it is intentionally constrained to not go beyond that for things beyond what that…

> for things beyond what that gives you, I am not afraid to recommend scripting

I'm not suggesting that you don't. I'm suggesting that it's quite similar to SvelteKit, Remix, and now Next.js, and other form-friendly frameworks in what you'd need to know in order to do a non-trivial full stack JavaScript project that supports progressive enhancement.

Re: htmx

#87
post #74
post #42

Earlier quoted context omitted.

Could you elaborate? Genuinely curious.

let's say that you have an upvote button Upvote Well where is this notification-bar? It could be anywhere on the page. Maybe it was introduced by another htmx action from another endpoint. Answering this simple question could take a lot of work. There is no way to work it out systematically short of auditing every interaction on the page.

HTML ids are globally unique so the answer is wherever `id="notification-bar"` lives.

Re: htmx

#88
post #74
post #42

Earlier quoted context omitted.

Could you elaborate? Genuinely curious.

let's say that you have an upvote button Upvote Well where is this notification-bar? It could be anywhere on the page. Maybe it was introduced by another htmx action from another endpoint. Answering this simple question could take a lot of work. There is no way to work it out systematically short of auditing every interaction on the page.

What’s the difference to writing vanilla JS to do the same thing?

Re: htmx

#89
post #8

For those with flexibility or a new project, also consider Phoenix LiveView. It’s been a joy to work with so far.

Or possibly Hotwire! (Turbo frames really) [0] Also found it to be wonderful to work with. [0] https://hotwired.dev

There are a variety of these types of frameworks for most peoples' favourite web-programming language (LiveView, Hotwire, LiveWire, Blazor...).

Re: htmx

#90

I continue to be impressed at the effort people will put into avoiding writing any JavaScript. Is it really easier to learn yet another DSL embedded in attribute tags rather than taking a day to setup your JS dev environment and then writing idiomatic code for running inside a web browser? Surely your htmx project will eventually cross a complexity threshold where you've added enough scaffolding that you may as well…

It's not that I avoid JavaScript, it's that I want my work to be accessible to someone without JS as a requirement, for whatever reason they may be in that state and configuration, whether by choice or not. I write plenty of JS (12% of my biggest project, according to GitHub), but it's added onto HTML in such a way that the HTML still works for: * a security-minded person who has it turned off in their browser, * a u…

Every site I build works with JavaScript disabled. I use Next.js with server side rendering so that the initial page load is an accessible HTML document that is progressively enhanced for those with JS enabled during hydration by adding interactivity and smooth client side page transitions without full page reloads.

None of this is possible with HTMX if the user has JavaScript disabled. The first step to using HTMX is to import a JavaScript file from a CDN, and none of the features for partial page replacement will work without it. Whereas with Next.js, with JavaScript disabled, a Link will revert to a full page load where the next page is rendered on the server. It will be progressively enhanced to what appears to be a partial page load by using the same JavaScript that would render the full page on the server to instead render it on the client starting from the current state of the DOM.

Post reply on HN