Live data from Hacker News

Show HN: htmz – a low power tool for HTML

leanrada.com

31–40 of 256 posts

Re: Show HN: htmz – a low power tool for HTML

#31

> Not even a backend is required. > In a nutshell, htmz lets you swap page fragments with HTML from the server using vanilla HTML code. So a backend is needed....

Oops, it's just a mistake on word choice in the nutshell summary. This works on static files like on a local filesystem (in that case the "server" is the local filesystem that serves me files that happen to be html)

Edit: on second thought, direct filesystem access has different origins which would mess with iframes. I'm not on the computer now to test. But at the very least you need a basic web server that serves files.

Re: Show HN: htmz – a low power tool for HTML

#33

That's a great hack and it shows how close the browser is to offering SPA natively. Just a few attributes and we could avoid the iframe. It's probably more useful to prove a point than an actual day to day tool. And the point seems to be: htmx is too much trouble for what it offers. We just need HTML native ajax.

Yes this was a response to htmx. It was a half-parody half-I wanna make it work project. Like https://github.com/vilgacx/aki I would fear if anyone wants to use this in production BUT I would love someone to get inspired and use the concepts rather than the actual code. Hmm maybe i should write a disclaimer...

It sounds like 'probably, yes' to adding a disclaimer, if only because I rather took it at face-value seeing it posted here on QBN so bookmarked for investigation later... .

Re: Show HN: htmz – a low power tool for HTML

#34

Reusing the element like this is a bad idea - it has very specific behavior in browsers. In a shadow root it'll be replaced by the children of the host element, no matter what the library does. HTML already has an inert element for things like this.

Thanks for the suggestion, I'll update the examples.

Edit: that is, after I wake up...

Re: Show HN: htmz – a low power tool for HTML

#35
post #16

Earlier quoted context omitted.

The inline editing demo also has a separate URL for the "we're editing" state

Yeah it's terrible in some use cases. If only HTML provided a way to navigate without adding a history entry, like . If this was a real product i would market it as "Native time travel debugging! Go through your application state as you would go through your browser history!"

That would be terrible UX.

The real answer is that web developers should stop using anchor tags to target non-stateful links and should properly handle navigation to pages that are short lived.

But that battle is a bit like asking people to use their turn signals when merging.

Re: Show HN: htmz – a low power tool for HTML

#36
post #9

Given that this uses `target`, doesn't it mean that unlike htmx you can't easily make this gracefully degrade when JS isn't enabled? And, yes, I know, saying "when JS isn't enabled" in 2024 is a bit like saying "when the user is on Mars and has a 10 minute RTT" but forgive me for being an idealist.

> being an idealist

Could you describe your ideals for why websites should gracefully degrade without JS enabled? It’s not an unpopular view on HN, but from my perspective as a web developer, JS is a part of browser application just like HTML, and there’s no reason for the website to work if you’ve disabled a part of the browser.

I suspect “doesn’t have JavaScript” is being used as a proxy for a lot of other ideals that I do understand, like “should work on as many devices as possible” but that’s a rough correlation and doesn’t make the use of JS inherently bad.

Re: Show HN: htmz – a low power tool for HTML

#38
It's a fun one liner, but what is the use case?

When I want to replace some element using JS as the user clicks a link, it is progressive enhancement.

Usually links enable history navigation. If you do stuff like this, you need to code it in a way that uses the history API to fix it for users with JS enabled (majority of users).

If you don't want history navigation and URLs, why do you use links?

This breaks history navigation and bfcache for no good reason, or am I missing something? bfcache already provides SPA-like speed, or even better.

No need to avoid regular links if you e.g. link from a list to a detail page.

Also:

> No preventDefaults. No hidden layers. Real DOM, real interactions. No VDOM, no click listeners. No AJAX, no fetch. No reinventing browsers.

So many words saying nothing, just to cater to some sentiment. fetch is part of browsers by the way.

If I need to replace an element as the user clicks a link, I can code it myself (without using this abstraction layer, however thin it is). I also don't need an iframe for doing this. And preventDefault is aptly named and a good reminder for what progressive enhancement should do. If it's not meant to be a link, don't use a link.

And if you want to react to clicks, you know, use click listeners (event handlers). Where's the problem?

It is understandable to developers and uses native browser functionality as intended. As opposed to this hack, which I'd find pretty glaring, bug-prone and hard to understand, would I have to debug an issue on some page that uses this snippet.

To me this seems like useless indirection and technical debt. If you really need low-code AJAX "links" (who says you need that, if you don't want an SPA?), code yourself some understandable JS that is properly tailored to your site and respects history navigation, or use a library that is a good fit for your concrete use case.

As a joke, I like it though…

Re: Show HN: htmz – a low power tool for HTML

#39

Reusing the element like this is a bad idea - it has very specific behavior in browsers. In a shadow root it'll be replaced by the children of the host element, no matter what the library does. HTML already has an inert element for things like this.

Slight correction - is not inert for users who use screen readers, though in this case it shouldn't cause issues. If you need an actual inert element, use a div.

Re: Show HN: htmz – a low power tool for HTML

#40

That's a great hack and it shows how close the browser is to offering SPA natively. Just a few attributes and we could avoid the iframe. It's probably more useful to prove a point than an actual day to day tool. And the point seems to be: htmx is too much trouble for what it offers. We just need HTML native ajax.

Yes this was a response to htmx. It was a half-parody half-I wanna make it work project. Like https://github.com/vilgacx/aki I would fear if anyone wants to use this in production BUT I would love someone to get inspired and use the concepts rather than the actual code. Hmm maybe i should write a disclaimer...

Love it! I think this idea has some legs in that a programmer can build their own f****k. Bundling only the pieces that they actually use. I don't see why it should not be used in a production environment...other than someone in the internet disapproves...a fear many of us suffer from. It's a simple idea & can be easily managed in a codebase.

In he spirit of breaking apart HTMX piece by piece, I created hyop (Hypermedia/Hydration Operation). It weighs in at 61 B but uses the "hyop" attribute. I know, I know, I'm bad...but at least I save bytes.

https://github.com/hyopjs/hyop

I'm going to use some of your concepts, with credit of course...like the snippetware idea among others.

Post reply on HN