Live data from Hacker News

Htmx Is Composable?

timkellogg.me

31–40 of 69 posts

Re: Htmx Is Composable?

#31
I couldn't get it to work with single-spa, which is what our company's UI framework uses to compose components built by different teams.

It seems like the two approaches are at odds with each other anyway, so perhaps this won't ever be possible.

Re: Htmx Is Composable?

#32
post #14

I am confused about htmx because if it is about AJAX, they don't replace the window URL as user clicks about and around unless you explicitly tell HTMX to do so. And if you step into that realm of keeping the window URL in sync with where exactly the user is in the app, then you're almost already into realm of SPAs but without having the full set of tools that go with SPA. Any open source project done in HTMX that ha…

Keeping the url in sync can be done by tracking whether the request has the `HX-Request` header in it and then returning either a partial template or the full the template, example of the helper - https://github.com/Austionian/bl0g/blob/46182cf762e9acefc35e...

The great part of this, too, is caching these responses is still simple with the a `Vary: HX-Request`

Re: Htmx Is Composable?

#33

One thing I see lacking with HTMX is that, eventually, someone will want to package and distribute a third party component. You say "but it's meant for small things not requiring much scripting" and I say "I don't believe you - once it's in it will grow indefinitely". This is definitely possible, but unless you are using WASM or something you would have component libraries specifically built for a backend language or…

HTMX users just use existing JS components.

It's not an XOR proposition.

Re: Htmx Is Composable?

#34

One thing I see lacking with HTMX is that, eventually, someone will want to package and distribute a third party component. You say "but it's meant for small things not requiring much scripting" and I say "I don't believe you - once it's in it will grow indefinitely". This is definitely possible, but unless you are using WASM or something you would have component libraries specifically built for a backend language or…

It's already like this for complex widgets, think of wysiwyg editors with file upload, usually it is necessary to provide a compatible backend for the file upload and management

Re: Htmx Is Composable?

#35
post #15

Earlier quoted context omitted.

I think the key feature of htmx that often people overlook is that you can update several elements with one html response The attribute is the following: https://htmx.org/attributes/hx-swap-oob/

that's even easier to do in react though. If I say, update the cart, and update my cart state in redux, then every component rendering the cart (say, header, checkout component, shipping progress bar) will update seamlessly. To me htmx seems weird in its mixing of logic / API separation layer with the UI separation layer. I can see it making sense on single/small team projects and appreciate the lack of bundling and…

It definitely feels weird in htmx.

It is easier in React if you are using a centralised state manager, yes. I prefer it, it is more explicit. If you use Context to set state it can come from anywhere. In this sense, it is even easier in Elm, since if you use Elm you are using one (redux was inspired by it iirc) ;o)

I think htmx makes sense really at the html level, like rest (I believe that is the goal of the project), because it would be framework agnostic. Then some boilerplate on top would fix these issues. You could define some central state in a single place and generate all the references (hx swap oob attributes). The basis is solid imho.

The most attractive thing for me would be that it would stay stable (like rest), but I agree right now a subset of react (choose state manager, styling method, ssr, etc) is easier/quicker. It needs to be constantly updated, though, and dependencies can creep in quickly if a team is not disciplined enough.

I agree with the weirdness of mixing logic an ui. I remember when css, html, and js were supposed to be kept separate. Then components in jsx mixed them, and it was useful. If htmx proves useful, the mixing of concerns does not differ much (not the same but it rhymes)

Re: Htmx Is Composable?

#36
post #15

Earlier quoted context omitted.

I think the key feature of htmx that often people overlook is that you can update several elements with one html response The attribute is the following: https://htmx.org/attributes/hx-swap-oob/

that's even easier to do in react though. If I say, update the cart, and update my cart state in redux, then every component rendering the cart (say, header, checkout component, shipping progress bar) will update seamlessly. To me htmx seems weird in its mixing of logic / API separation layer with the UI separation layer. I can see it making sense on single/small team projects and appreciate the lack of bundling and…

I am not a web dev, but I do it occasionally for fun, or want to put a script on the web, and when I saw htmx I was excited because I immediately grokked it and knew how to use it for my purposes. React looks cool, but intimidating for someone who is not a web dev. Maybe htmx is not for making big complex apps.

Re: Htmx Is Composable?

#37

One thing I see lacking with HTMX is that, eventually, someone will want to package and distribute a third party component. You say "but it's meant for small things not requiring much scripting" and I say "I don't believe you - once it's in it will grow indefinitely". This is definitely possible, but unless you are using WASM or something you would have component libraries specifically built for a backend language or…

HTMX users just use existing JS components. It's not an XOR proposition.

But you should be able to distribute bundled backend and frontend logic given its paradigm. There is no guidance on what it would take to do this, or what the interface for the components should be to enable it, or how you should build and share it.

Without both, I don't see the point because then you need to potentially mix multiple frontend frameworks unless you are strictly using WebComponents.

It's not XOR, but it should be possible to never leave HTMX. If you might need to go outside it anyway, then there is no point - you lose SSR if you just mount a React component anyway.

I understand the argument that HTMX can be complementary, but personally I'm not looking for a complementary technology. Show me how I can use it exclusively and I'll be more interested.

Re: Htmx Is Composable?

#38
post #14

I am confused about htmx because if it is about AJAX, they don't replace the window URL as user clicks about and around unless you explicitly tell HTMX to do so. And if you step into that realm of keeping the window URL in sync with where exactly the user is in the app, then you're almost already into realm of SPAs but without having the full set of tools that go with SPA. Any open source project done in HTMX that ha…

Doesn't this go against the philosophy though? I'd expect navigation to happen mostly with plain old html navigation

Re: Htmx Is Composable?

#39

Earlier quoted context omitted.

Why did WPF go out of style? (or did it? idk) It seems like a good pattern, but it's always good to look at historical cases for the gotchas

XAML is not a learn in a weekend type of deal and most dev don’t want to put the time to reading a proper book to learn it.

When I was last dabbling with WinUI/Win App SDK it honestly never even crossed my mind to read a book, but in retrospect that sounds like a good idea. Figuring out how to do X basic thing in XAML through googling was frustrating largely due to how many different flavors of XAML exist now.

Re: Htmx Is Composable?

#40
HTMX is neutral to composability, since it's limited to connecting and orchestrating parts of a system that may or may not chose to provide components.

Does your backend has components? Does your scripting toolkit has components?

HTMX doesn't care either way, and will use whatever you give it.

You can pick reusable django forms, alpine js, some manually created boundaries, a jquery module... You can even drop react on a single page because there is a widget you like and it's not loaded often.

People may be tempted to talk about HTMX using irrelevant points of references.

It's not providing an SPA with a component architecture, that's the point.

The readers that are very used to modern JS stacks and never had to deal with the web before 2010 may want to read:

https://www.bitecode.dev/p/a-little-taste-of-htmx-part-1

This will give a better idea of how to think in HTMX, which is just a new trick for an old dog.

It's better to use this tool for what it is, with its limits and strengths rather than trying to make it into something it's not.

The reason HTMX can't do many things react is good at is because it's by nature the opposite of react.

Post reply on HN