169 points · by fanf2 · 1y ago · 116 comments
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.
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>
If so, it's not because for lack of a written down philosophical framework. See Hypermedia Systems by Carson et al.
That’s the path for ultimate long term functional web pages!
HTML + CSS + sprinkles of vanilla JS is the perfect recipe for readable, fast, and high resilient web pages.
Use plain HTML wherever possible for long term functional web pages!
For long term web, I stay way from SPA with a long stick.
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
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.
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:
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".
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.
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.
That's a feature.
> and they should not know.
Yes, a fetch failing, DOM being updated is standard web behavior, interns handle that.
Reality has entered the chat.
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...
This looks appealing where it makes sense (page transitions, table sorting/pagination) and if Firefox gets around to adding it.
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.
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.
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.
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.
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.
> 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.And the predictability is a boon. Open in new tab, back button etc.
- something that kinda looks like full reload
- but with all problems of client side routing
- and without preserving the DOM state like SPA would
- and you don't get the immediate response that is the main reason to build the SPA in the first place
In fact, it's often even slower than native navigation, because native navigation can start processing the stream during download and there's overhead with pre and post processing of the response in the boosted link version. Try to profile GitHub links to see what I'm talking about, opening a link in new tab can be 2x faster than clicking in the same tab.
It's written in Javascript, so yes, some vanilla JS can do the same thing; but this library makes that experience easier for the masses, and likely well-tested to the point where more trust can be given to it to be correct.
In my opinion, in five years no one uses htmx, but another shiny toy. Hence, how about not starting to use it at all?
In context, it's clear that I'm not saying "everyone should use htmx," but rather "if you are using htmx, here is how I recommend you do it."
As for the shiny object concern, I have a talk (which you can also find on this blog) called "Building the Hundred-Year Web Service", that dives into that question.
I think most things done currently with the frontend "frameworks", could be achieved with standard HTML5+JS, without any "build steps" or other bloat involved.
This said, there is a case for building on a commonly used mature platform, such as React, to speed up the development cycle and in order not inventing the wheel again.
That makes the time since it's inception to date longer then the time between initial react release and initial intercoolerjs release
Somehow every other JS frontend framework manages to hook into the History API just fine?
I think this is industry standard practice in 2025, right?
I didn't realize that this will make the back button effective unusable, because the redirected url will still be in the history unless you manually redirect with a bare component. Hence whenever someone used back, the redirect pushed them back to the route they just left. I just used it as I came from a backend perspective, where redirects are fine as there is a delay between the request and the redirect, giving the user the time to just double press back... Obviously not so with a JS redirect.
I believe that continues to be an angular Anti-Feature to date.(Just checked, they still have it in their docs - without the ability to surpress the redirected history entry as far as I can see)
Edit: "Normal/traditional frontend" here means both vanilla (HTML+JS+CSS) and the most popular frameworks (React, Angular, Vue, Next).
You can whip up a simple html form and spruce it up with htmx so it feels “modern” to current users, with little effort and changes and importantly without having to learn the insanity that are modern front end stacks. Not only curmudgeons from the 90s like me benefit from this!
When an interactive "widget" is needed, I try to simply embed that in one HTML page, and avoid to make the whole app an single page application (SPA).
SPAs are problematic because you need to manage state twice: in the BE and FE. You also may want a spec'ed API (with client library generation would be AWESOME: GraphQL and OpenAPIv3 have that and it helps a lot).
> so you use normal frontend technologies
This is the problem. "Normal" means React/Vue/Angular these days and they are all shit IMHO. This is partly because JS is a rampification and TS fix only what could be fixed by _adding_ to the language (since it's a superset). So TS is not a fix.
I had great success with Elm on the frontend. It's not normal by any norm. Probably less popular than HTMX. But it helps to build really solid web apps and all devs that use it become FP-superstars in a month.
Tools like ReasonML/ReScript and PureScript may also have these benefits.
OK, this helps explain some of the reasoning.
Unfortunately, that means that the tradeoff is that you're optimizing for user experience instead of developer experience - htmx is much easier for the developer, but worse for the user because of higher latency for all actions. I don't see how you can get around this if your paradigm is you do all of your computation on the server - and if you mix client- and server-side computation, then you're adding back in complexity that you explicitly wanted to get away from by using htmx.
> "Normal" means React/Vue/Angular these days
I didn't mean (just) that. I included vanilla webtech in my definition of "normal" - I guess I should have clarified in my initial comment (I just meant to exclude really exotic, if useful, things like Elm). Does that change how you would respond to it?
If your implementation is poor
> all of your computation on the server
You doing weather forecasting? Crypto mining? What "computation" is happening on the client? The only real computation in most web sites is the algorithmic ad presentation - and that's not done on your servers.
Latency is something to consider yes. Besides that we should not forget it is easy to make an HTMX-mess: HTMX's not a good fit not fit for all use-cases and some approaches are dead end (the article even talks about this, but you find more testimonies of this online). With HTMX you also create a lot of end-points, usually without a spec: this can also become an issue (might not work for some teams).
> if you mix client- and server-side computation, then you're adding back in complexity that you explicitly wanted to get away from by using htmx.
Exactly! A good reason not use HTMX, if you need a lot of browser-side computation.
> I didn't mean (just) that. I included vanilla webtech in my definition of "normal"
If you mean "just scripting with JS (w/o any framework)" then I still do not think this is an acceptable alternative to compare HTMX to. IMHO you have to compare with something that that provides a solid basis to develop a larger application on. Otherwise you may say HTMX is great because the status quo (vanillaJS/React/Vue/Ang) is such a mess.
Not really, your backend has rich domain logic you can leverage to provide users with as much data as possible, while providing comparable levels of interactivity. Pushing as much logic (i.e., state) while you're developing results in a pale imitation of that domain logic on the front end, leading to a greatly diminished user experience.
That's an assertion I don't agree with.
Data still needs to come from or go to the server, whether you do it in a snippet of HTML or with an API call.
In either case, latency is there.
The part about users being more latency-limited than compute-limited, or wanting to push as much to the browser as possible?
The former is somewhat hard to quantify, but most engineers building interactive applications (or distributed systems, of which interactive client-server webapps are a special case) have far more trouble with latency than compute.
The latter is definitely true.
> Data still needs to come from or go to the server, whether you do it in a snippet of HTML or with an API call. ... In either case, latency is there.
This is definitely incorrect.
Consider the very common case of fetching some data from the server and then filtering it. In many, many cases, the filtering can be done client-side. If you do that with an interactive frontend, then it's nearly instant, and there's no additional fetch to the server. If you shell out to the server, then you pay the latency penalty, and incur a fetch.
"In either case, latency is there." is just factually wrong.
https://htmx.org/essays/a-real-world-react-to-htmx-port/
https://htmx.org/essays/another-real-world-react-to-htmx-por...
This implies you value optimization over other concerns, will do ssr & rehydration, etc.
Htmx has been the best performant of all my tries before.
HTML is fast. (also, I use svg everywhere I can)
My main issue with SPAs, and client rendering in general, has always been the attempt to client render state that is persisted elsewhere.
There are certain pieces of state that really do live on the client, and for that client rendering is great. A vast majority of cases involve state that is persisted somewhere on the server though, and in those cases its needlessly complex to ship both the state and an entire rendering engine to the browser.
Is JQuery normal? What about the Google Closure compiler? ColdFusion? Silverlight? Ruby and CoffeeScript? Angular? SPA React with classes? Elm? SSR React with a server framework? Client-only vanilla DOM manipulation?
Your idea of normal is presumably whatever you’ve been using for the past few years. For someone who starts using Htmx now, it becomes normal. And if there’s enough of those people, their idea of normal becomes commonplace.