Less Htmx Is More
118 comments
·April 8, 2025kolektiv
Manfred
I believe some of these issues are caused by framework abstractions.
New developers learn the framework and never learn how HTTP and HTML work.
Experienced developers have to learn how to punch through the framework to get to these features we get automatically with statically hosted assets.
kolektiv
Very likely. I remember reading a while back about developers who thought of rendering things on the server side as novel, which was absolutely wild to someone who was writing web pages before JS was a thing! It's such a shame because HTTP + HTML is actually a very, very simple system to learn with literally decades of hard-won knowledge baked in (particularly HTTP and surrounding standards). People end up inventing incredibly complex solutions to problems that could have been alleviated by reading a few RFCs.
codegeek
Pretty much. I can't tell you how many times I interview these "framework developers" and they cant tell me how a regular HTML form submission works. Boggles my mind.
xiphias2
As you can see even the basic documentation is compromised at this point:
https://unplannedobsolescence.com/blog/behavior-belongs-in-h...
<button onclick="alert('I was clicked!')">Click me</button>
,,You can find HTML attribute equivalents for many of the event handler properties; however, you shouldn't use these — they are considered bad practice. It might seem easy to use an event handler attribute if you are doing something really quick, but they quickly become unmanageable and inefficient.''
,,You should never use the HTML event handler attributes — those are outdated, and using them is bad practice.''
And then proceeds to suggest this:
<button>Click me</button>
<script> const btn = document.querySelector("button")
btn.addEventListener("click", () => { alert('I was clicked!') }) </script>
After this, next step would be putting javascript to a separate file, and on a slow mobile connection in a random airport with thousands of people using the same wifi, a simple working code gets timeouts.
20 years ago all I needed to know was this, and it worked great:
<button onclick="alert('I was clicked!')">Click me</button>
weinzierl
> "Like any new tool, especially a tool that got popular as quickly as htmx, there are differing schools of thought on how best to use it."
If so, it's not because for lack of a written down philosophical framework. See Hypermedia Systems by Carson et al.
vagrantJin
Simplicity is a non-starter these days.
rpgbr
> Like any new tool, especially a tool that got popular as quickly as htmx, there are differing schools of thought on how best to use it. My approach—which I believe necessary to achieve the results described above—requires you to internalize something that htmx certainly hints at, but doesn’t enforce: use plain HTML wherever possible.
That’s the path for ultimate long term functional web pages!
taneq
Having been out of the web dev game (or at least ‘front end’ as you cool kids are calling it? ;) for a while, I was a little dismayed when I asked an LLM for a web page that did a specific thing. It required Bootstrap and Angular and a bunch of other stuff. Asked it nicely to redo it in plain HTML and JS and the resulting code was simpler and no longer then the original, with no external dependencies.
mycall
In the pursuit of ultimate long term functional web pages, how does that affect maintainability, e.g. changing requirements? In my mind, the less characters used the less effort it takes to change it, but this might be obsolete thinking wrt AI assisted (or fully written) sites.
rpgbr
I agree! As a journalist that codes his own site/blog, I've never took the time to learn anything more complex than good and old HTML and CSS to structure a page, and the short incursions I had in complex system (node, SCSS, frameworks), the returns for the kind of sites I developed was so little I couldn't be bothered to climb the learning curve.
HTML + CSS + sprinkles of vanilla JS is the perfect recipe for readable, fast, and high resilient web pages.
Ringz
Agreed! TLDR:
Use plain HTML wherever possible for long term functional web pages!
freeamz
I have made many many web pages over the last 15 years of so that is for just a few months or days. What I do is archive it on way back machine, and if the page works on way back machine then that is my stamp of approval for the page. It can also tell you the page is self contained! It works pretty well with WebGL and event audio playlist. There is NO point of making web dev so complicated just because FANNG company are using the framework. It is designed for they corporate structure. Anyone else should NOT use FANNG based framework!
For long term web, I stay way from SPA with a long stick.
can3p
There are two sides to the argument which I think should be treated separately: a) Is it a good idea overall? and b) is htmx implementation good enough?
a) I think so, yes. I've seen much more spa that have a completely broken page navigation. This approach does not fit all use cases, but if you remember that the whole idea of htmx is that you rely on webserver giving you page updates as opposed to having a thick js app rendering it all the way it makes sense. And yes, js libraries should be wrapped to function properly in many cases, but you would do the same with no react-native components in any react app for example
b) I don't think so. htmx boost functionality is an afterthought and it will always be like this. Compare it with turbo [1] where this is a core feature and the approach is to use turbo together with stimulus.js which gives you automagical component life cycle management. Turbo still has it's pains (my favorite gh issue [2]), but otherwise it works fine
[1]: https://turbo.hotwired.dev/ [2]: https://github.com/hotwired/turbo/issues/37
yawaramin
htmx boost functionality is an afterthought in the main use case it is marketed for (turning a traditional MPA into something that feels like a SPA), but it's actually super useful for the normal htmx use case of fetching partial updates and swapping them into a page.
If you do something like <a href=/foo hx-get=/foo hx-target="#foo">XYZ</a> the intention is that it should work with or without JavaScript or htmx available. But the problem is that if you do Ctrl-click or Cmd-click, htmx swallows the Ctrl/Cmd key and opens the link in the same tab instead of in a new tab!
But if you do <a href=/foo hx-boost=true hx-target="#foo">XYZ</a> everything works as expected–left-click does the swap in the current tab as expected, Ctrl/Cmd-click opens in a new tab, etc. etc.
Also another point–you are comparing htmx's boost, one feature out of many, to the entirety of Turbo? That seems like apples and oranges.
recursivedoubts
hx-boost is an afterthought and we haven't pushed the idea further because we expect view transitions via normal navigation to continue to fill in that area
htmx focuses on generalizing hypermedia controls:
https://dl.acm.org/doi/pdf/10.1145/3648188.3675127
we also have a minimalist version of the idea, fixi:
can3p
Thanks for the correction!
evantbyrne
Would like to second the turbo rec. I've had good results with it for nontrivial use cases. Would like to hear from people if they have different experiences. Also, praying that everything gets cached first load and hand waving that view transitions will eventually work is not a position I want to hear from an engineer in a commercial context. Really happy to see the author bring more attention to how good vanilla web technologies have gotten though.
axegon_
> Updates that users would not expect to see on a refresh (or a new page load)
I always hated this idea. As a user, a refresh indicates that something is happening and it's abundantly clear when something is wrong. People don't always handle errors and in all fairness they shouldn't - a developer has no way of knowing what custom stuff I have on my browser, whether I'm using any blockers or pi-holes or whatever and they should not know. Simple navigation, refreshes and server side rendering is something which worked great, the web was fast and could run on anything with a graphical output. These days a single page eats up 150+ mb while it loads. All that so the page doesn't "refresh".
sgt
It's not that smooth looking if a refresh takes 500 milliseconds. Then it flickers.
foobahify
500ms means a slow connection, high latency or significant bloat.
Optimising the page and using a CDN can help alot.
It is a shame HTML doesn't have rel="swap" in links to "swap" in a new page.
axegon_
Oh yeah a 15 second spinning circle and 250mb memory is sooooo much better than a 500ms refresh </sarcasm>
earthnail
A 2s spinning circle may indeed be better than a 500ms flashing reload. Try it on your mom (“waaah why did it flash??”).
I also dislike SPAs but there is business value in this slow spinner that you shouldn’t discount.
Luckily, turbo or htmx solve this just as well. And maybe even more importantly, I can’t think of a modern browser that still flickers.
sgt
I don't disagree with you :)
mattgreenrocks
If the layout hasn’t changed, then there is no flicker that I can tell on Chrome/FF at 144hz.
friendzis
> a developer has no way of knowing what custom stuff I have on my browser, whether I'm using any blockers or pi-holes or whatever
That's a feature.
> and they should not know.
Yes, a fetch failing, DOM being updated is standard web behavior, interns handle that.
axegon_
> interns handle that
Reality has entered the chat.
codemonkey-zeta
> “You didn’t solve anything! Doing validation is complex and you just magic wanded it away by designing a perfect interface for it.” Yes. Exactly. That is what interfaces are supposed to do. Better semantics make it possible for the programmer to describe what the element does, and for someone else to take care of the details for them.
Gosh I couldn't agree more, what a wonderfully succinct way to communicate what I spend a ridiculous amount of time trying to explain to my colleagues when designing programs!
[EDIT]: I just realized I had read this on one of the linked articles https://unplannedobsolescence.com/blog/behavior-belongs-in-h...
seanwilson
Anyone replace some HTMX usage with the View Transition API that's now in Chrome and Safari? https://developer.chrome.com/docs/web-platform/view-transiti...
This looks appealing where it makes sense (page transitions, table sorting/pagination) and if Firefox gets around to adding it.
_heimdall
I really want to like the transitions API but I've been frustrated by it multiple times.
It feels like they wanted to build page animations similar to what Windows Phone had 15 years ago. That would be great, Windows Phone transition were surprisingly nice.
It just doesn't work on the web though, its an after thought. Animations on windows phone only worked because it was designed into the UI library and rendering engine from the beginning.
seanwilson
Can you go into more detail about what's frustrating? You can customize the animations, right?
_heimdall
Yeah you can customize them a bit.
What I've always wanted to be able to do though is restyle the actual DOM element as it animates from one part of the screen to another. Unless this changed pretty recently, my understanding is that the browser is basically grabbing a screenshot of the DOM element before it navigates and animates the snapshot itself across the screen.
I've also run into random issues related to having to tag the element targets. I don't remember all the details now so I can't give a great example, but especially when using libraries like HTMX I was having issues trying to make sure the right elements were tagged to animate correctly.
Conditional animations can be done, though its a little odd to wrangle and you can end up with code mixed between HTML, JS, and CSS to work with it.
titaphraz
I really hope this won't become the new craze. The examples triggers all my irritation triggers. I couldn't use a website like that.
t-writescode
I have used htmx just a little bit; but I have found htmx + solid.js for some small reactive components to be ... very, very pleasant and very much else of what this blog post says to be accurate.
I've written a lot more html than I have in the past and it just ... feels good? html has upgraded quite a bit in the last decades since I learned it.
ksec
>Triptych—the HTML proposals that Carson and I are working on—would render htmx obsolete for the type of website I describe here.
Which we discussed here [1], is still no where near getting even looked at. Browser maker are not interested in anything HTMX. Vast majority of browser developers still want JS driven web apps, served with AVIF image.
sgt
How do you get flicker free navigation using htmx without using hx-swap or boost? I see that this article refers to https://unplannedobsolescence.com which has a header that remains the same, but it also doesn't change. Normally a header will do some type of change, e.g. showing which menu item is currently selected. That's when the flickering starts, in my experience.
ahmetsait
Browsers already have built-in mechanism to prevent flicker while switching pages, unless your page has issues such as flash of unstyled content or something similar.
sgt
Yeah you are right. I can't reproduce it at the moment. Maybe I am thinking of a couple of years ago when the browser did in fact flash for the same.
zigzag312
I think scroll position is the one that is not preserved.
davedx
Does anyone have examples of non trivial websites or apps built with Htmx?
Ringz
> The idea here is that the website still has a sound URL structure, which is managed by the core browser functionality, while interactivity is carefully layered on top, with targeted updates.
It’s a long time since I have to work with websites. JQuery was the hot stuff back then. But we didn’t used it. It was all HTML and a Java backend. This sentence implies that right now basic stuff isn’t managed by the browser (but by React, Vue and so on?) which seems to be simply wrong.
CharlieDigital
> This sentence implies that right now basic stuff isn’t managed by the browser (but by React, Vue and so on?) which seems to be simply wrong.
That's exactly what's happened. A React SPA .html is just an empty shell. A Next.js app renders HTML using React on the first load and then becomes an SPA on the client.foobahify
Yes if you click a regular link in a modern browser on a noJS or lowJS reasonable size page it is darn fast.
And the predictability is a boon. Open in new tab, back button etc.
It is amazing how quickly a simple, traditional, "collection of pages" type website actually works if you don't do annoying things to slow it down. Most websites would be absolutely fine if a) HTTP was used reasonably well to set things like cache headers, and so (as mentioned in the article) and b) if a load of user-irrelevant stuff like tracking and advertising code wasn't thrown in as well. A simple page with standard HTML, passably optimised assets where needed, and only the JS needed for actual functionality, should be almost instant on most modern connections.