Live data from Hacker News

htmx

htmx.org

211–220 of 291 posts

Re: htmx

#211

Learning to use any new tool comes at a time cost, and if I learn this and then a newer, more convenient tool emerges that can replace it, I get stuck in the question. Are people driving the tools? Or are the tools binding people?

Perhaps too cynical from my dislike of frontend but I sometimes suspect the churn is spicing up monotonous work for some people.

Yes, I also don't like doing front-end development work, not because front-end development work itself is offensive, but doing front-end development work is a very meticulous thing, which requires me to invest a lot of time, which will reduce my energy investment in other work content.

Re: htmx

#212
post #32

can htmx be used offline? i.e. am I screwed if I load an htmx page, close a laptop and get on a plane?

If the page has loaded, it's loaded. There's no moving parts once you have rendered HTML from the wire.

Re: htmx

#213

Earlier quoted context omitted.

It is explicitly NOT a silver bullet https://htmx.org/essays/when-to-use-hypermedia/#hypermedia-n...

I'd like to point out that if you require offline functionality in one project that it likely isn't a good fit for your other project that doesn't require offline functionality. We all have finite time and it's great to learn something once and be able to use it multiple times.

Offline functionality naturally requires client-side code to handle storage, caching, synchronization etc, so client oriented frameworks are preferable in those scenarios. However, this comes at the cost of additional complexity, and I argue that this complexity may be unnecessary and htmx may help you achieve your goals easier

You said it yourself:

> We all have finite time and it's great to learn something once and be able to use it multiple times.

We all have finite time and it's great to use tools that help us work efficiently, following the strengths of those tools, instead of having to maintain unnecessarily complex solutions

Re: htmx

#214

I'd still pick Unpoly over it. Seems far more high level, feature rich and easier to use although less popular. And if I wanted a popular approach I'd pick Hotwire which can be used with any backend framework anyways. https://unpoly.com/ https://hotwired.dev/

Can you expand a bit on why you prefer unpoly over htmx ? I like htmx but I'm genuinely interested in alternatives around the same concept.

Re: htmx

#215
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.

That's because this example is an anti-pattern, the swap should be local [1], the button changes itself (to an orange arrow, to disable itself, etc) and the notification tag (#notification-bar) should be responsible of its own behavior.

An idea could be that the notification bar is polling a notification endpoint every Xsec or on a specific event [2], or if you want to be fancy with WebSockets [3]

[1] They actually talk about this: https://htmx.org/essays/locality-of-behaviour/

[2] for example afterRequest or afterSwap : https://htmx.org/events/#htmx:afterRequest

[3] https://htmx.org/extensions/web-sockets/

Re: htmx

#216
post #121

Hmmmm... no. This: Click Me Should be just this: Click Me This way, no magic would be needed, a lot of indirection and complexity would be avoided and everybody who knows HTML and JS could immediately read and understand it: - When does something happen here? When the button is clicked. - What does happen? htmx.post() is called.

Do you consider the href attribute of anchors "magic"?

Re: htmx

#218
post #121

Hmmmm... no. This: Click Me Should be just this: Click Me This way, no magic would be needed, a lot of indirection and complexity would be avoided and everybody who knows HTML and JS could immediately read and understand it: - When does something happen here? When the button is clicked. - What does happen? htmx.post() is called.

I like your change. Much clearer. Makes me more interested than the current syntax.

Your opinion is totally valid. However, is it really difficult or tricky to recognize that 'click' the default event of a 'button' tag? Isn't 'onclick=' kind of redundant?

Re: htmx

#219

I personally don't see the utility in this too much, but then I'm old fashioned and go out of my way to use as little JS as possible, doing everything via CSS as much as I can. Even though JS is ubiquitous and small, well written JS is harmless, I still try to avoid it like the plague. Maybe just to somewhat fight back against all the excessive JS that plagues every site.

I'm old fashioned and go out of my way to use as little JS as possible The point of HTMX is to avoid writing custom JavaScript.

But it does that by including a bunch of JavaScript and obscuring it. So not exactly including as little JS as possible.

Re: htmx

#220
post #210

Earlier quoted context omitted.

You are missing the fact that html has very restricted list of events that can be defined in an attribute. Htmx allows to listen on any event, plus some extra features on top, such as event throttling, polling, synchronization between elements. Stylistically I can see the appeal of your proposal and even agree on some ways, but it's not functionally equivalent https://htmx.org/attributes/hx-trigger/ https://htmx.org/…

What would be a simple example of an event that you want to define inline but can't in plain html? Can you give minimal example on jsfiddle so we can compare different approaches?

Here you go: https://plnkr.co/edit/DQJrBWWQFgHtpltf?open=index.html&previ...

Another big aspect of allowing to handle any event is integration with other JS libraries. See this basic example of interacting with Sortable JS [1]

Also, htmx has a response header called `HX-Trigger`[2] which lets server trigger custom events on the client and you can handle those events as well[3]. This is quite useful if you have interdependent data and you want to refresh regions on the page in response to user actions somewhere else (for which htmx allows multiple different patterns for different scenarios)[4]

[1]: https://htmx.org/examples/sortable/

[2]: https://htmx.org/headers/hx-trigger/

[3]: https://htmx.org/attributes/hx-trigger/#triggering-via-the-h...

[4]: https://htmx.org/examples/update-other-content/

Post reply on HN