10 ms·
Htmx 2.0.4 Released
- _heimdall 2y ago> Calling htmx.ajax with no target or source now defaults to body (previously did nothing) This one jumped out to me as an interesting one for a patch release. Changing the default behavior feels like a breaking change, though hopefully there weren't sites expecting an ajax call to not do anything.
- cschep 2y agowhy would you call it expecting it to do nothing?
- beanjuiceII 2y agowhy is the wrong question, because it doesn't matter
- cschep 2y agoof course it matters. not all workflows are worth preserving at all costs. there could be a really important trade off lurking, I'm not familiar, which is why I asked! https://xkcd.com/1172/ https://xkcd.com/1172/
- tomjakubowski 2y ago> though hopefully there weren't sites expecting an ajax call to not do anything. thatsthebeautyofit.com in shambles
- recursivedoubts 2y agoyeah, the htmx JavaScript API is not widely used, but I agree it's right on the edge of what's acceptable in a patch release
- chrismorgan 2y ago> though hopefully there weren't sites expecting an ajax call to not do anything It didn’t need to do nothing, it just needed to have no visible effect. I would be absolutely astonished if this affected no one. It’s very easy to imagine someone having written htmx.ajax("GET", "/some-tracker-that-returns-nothing-or-json-or-something") And now your body is clobbered, leaving either nothing behind or a raw JSON response or some such thing. Seriously. Should such a person have used fetch() instead? I dunno, probably; I don’t use htmx. This is an extremely breaking change.
- recursivedoubts 2y agoYeah I tend to agree this should have been in a minor rather than a patch release. The reality is that I tend to regard the JavaScript api as an afterthought (the html attributes are the main api) and the existing behavior seemed like a nonsensical bug, but on reflection I wouldn’t have changed the html api like that and should treat the JavaScript api the same way.
- _heimdall 2y agoThat's fair, I guess someone could be doing that. Not quite sure why you would though, if you're already in JS and aren't updating the DOM, fetch() would make more sense. Either way it sounds like this was a fix to a bug introduced in the last patch so the semver makes more sense here.
- latent22 2y agoActually this was just a stupid bug I introduced in 2.0.3 which was found soon after 2.0.3 shipped. I fixed a bug that allowed ajax api to target body and blow away your whole page in error if one of the selectors you pass in was not found. But It broke the default no source and target behavior but this is now fixed that 2.0.4 is shipped
- ahoka 2y agoThis is why I think semver is impossible to do in practice.
- deleted 2y ago[deleted]
- teruakohatu 2y ago> This is why I think semver is impossible to do in practice. The semver docs explicitly address this scenario. If a change in minor update breaks compatibility release a new minor update to revert the change.
- foldr 2y agoIt’s correct practice, but bad luck for anyone who ends up depending on the buggy behavior in 2.0.3. Their code will break when they upgrade to (say) 2.0.7.
- joshmanders 2y agoThis would make sense if 2.0.3 was released long enough ago for people to start using and relying on a bug, but it was released less than 2 months ago...
- latent22 2y agoThe bug in 2.0.3 just breaks one default use case and where you pass in no source or target to the api so anyone using this feature their app broke on upgrade to 2.0.3 and they had to set a source explicitly or revert the version. 2.0.4 just fixes this with no downside unless you like seeing console errors
- hipadev23 2y ago> Changing the default behavior feels like a breaking change I'm fine with breaking changes personally. An adherence to maintaining backward compatibility always is what leads to bloat and criticisms of "poor design" from HNers in the future. Keep it slim, have one way to do things, and avoid the disaster that is js and python today.
- Spivak 2y agoIt's not that there are breaking changes, but that breaking changes were introduced in a patch release.
- intalentive 2y agoHow is Python a disaster?
- deleted 2y ago[deleted]
- izietto 2y agoI'm not fine with breaking changes in a patch bump, otherwise it means versioning is useless
- PhilippGille 2y agoIn addition to what the siblings say, in case parent isn't aware of semantic versioning: https://semver.org/ https://semver.org/
- sethammons 2y agoBackwards compatibility is a mainstay in Go and I don't experience bloat, and, I believe, such goals are a hallmark of good api design. Source: over the last 20 years, built several and used many large code bases that have used for years and years that had different teams and individuals regularly committing into them.
- benatkin 2y agoThere's a question I've had about htmx for some time, might as well ask it here. Why does it keep the history cache in localStorage and not sessionStorage or memory? Some kind of a microoptimization? sessionStorage seems like it would be better to me if it's really a good default. I also think it should be publicized more, because it unexpectedly keeps stuff in a location that can be accessed more easily and beyond where the browser's back button cache can.
- recursivedoubts 2y agomemory wouldn't survive a page refresh sessionStorage wouldn't survive a tab close i'm not opposed to making the latter an option though
- benatkin 2y ago> memory wouldn't survive a page refresh That isn't very common. > sessionStorage wouldn't survive a tab close When a tab is restored, the browser typically restores sessionStorage. > i'm not opposed to making the latter an option though That isn't what I was getting at. If I'm going to buy into htmx, I want to understand the design. I wondered why this was the default, and why I hadn't seen it mentioned as a security concern.
- esperent 2y ago> When a tab is restored, the browser typically restores sessionStorage Is it guaranteed to do this? Otherwise, if it just sometimes does it, or different browsers handle it differently/may change in the future, it seems like a recipe for problems.
- hotpocket777 2y agoNot guaranteed, no. Thankfully. Chrome does, however, if the “resume where i left off” setting is enabled.
- johnfn 2y ago
- WD-42 2y agoNice boring release, just the way I like it. Thank you!
- xupybd 2y agoNothing new under the sun. This is just a rip off of intercooler js. Only without jQuery. Times moved on and someone copied the idea (exactly) but with the aid of modern JavaScript didn't need jQuery. I mean it's nice that it's a bit more modern but still.
- genocidicbunny 2y agoYou do realize that htmx is intecooler.js 2.0? Made by the same people, for the same purpose. And if you don't believe me, the intercooler.js homepage says pretty much the same exact thing.
- xupybd 2y agoI think you'll find there is some animosity https://x.com/intercoolerjs/status/1845878585078567084?t=p41Sc-8a7vnCLOgm9kmw2w&s=19 https://x.com/intercoolerjs/status/1845878585078567084?t=p41...
- deedubaya 2y agoAs ceo of htmx I’ll field any questions now
- recursive 2y agoI doubt that.
- recursivedoubts 2y agono, they are a CEO of htmx so are you: https://htmx.ceo https://htmx.ceo
- adzm 2y agoI'm sorry, can someone please explain
- joshmanders 2y agoAnyone can be htmx CEO, even you could be without knowing it. I'm an htmx CEO, btw.
- ossobuco 2y ago/u/recursivedoubts correcting /u/recursive has to be some of kind of joke you guys prepared in advance, right?
- recursive 2y agoNot prepared in advance, but I knew the user name on the htmx guy, so I just decided to use the word "doubt".
- xupybd 2y agoAs another CEO of HTMX, how do you feel about this release?
- mongol 2y ago
- sublinear 2y ago[flagged]
- xupybd 2y agoHarsh dude, why not just keep quiet?
- sublinear 2y agoSick and tired of any server-side rendering of web pages. If you don't have to deal with incident response you can be quiet. It doesn't scale and it complicates meeting any client requirements. Get this trash outta here. For real.
- xupybd 2y agoI worked with server side rendering for close to a decade. It's very reliable.
- sublinear 2y ago[flagged]
- xupybd 2y agoWhat happens when your static stie infrastructure goes down? I fear your argument is turtles all the way down. Edit: I'll show this to my boss. I'm sure he'll get a chuckle.
- sublinear 2y agoI hope he does because that's a huge sign your entire management structure is super out of touch and I hope you're next DOR or incident ressponse reveals the truth.
- 2y ago
- thekashifmalik 2y agoSo happy every time I see HTMX. I'm hoping there is more innovation in this space with React engineers rediscovering the benefits of server-side rendering and Backend-For-Frontend efforts. I think the perfect stack involves all 3 paradigms (initial loads, hypermedia loads and data/AJAX loads) used in parts of the application as makes sense.
- bogdan 2y ago> React engineers rediscovering the benefits of server-side rendering and Backend-For-Frontend efforts React 19 has just been released recently with server components and server actions. Worth having a look. It's a very powerful model.
- RamboRogers 2y agoHtmx belongs on a pedestal
- peterpost2 2y agoAgreed, web development without all the time consuming nonsense.
- euroderf 2y agoI'd like to see a demo of htmx talking to the WebAssembly HTTP capability component.
- ianpurton 2y agoWhat is that?
- euroderf 2y agohttps://github.com/WebAssembly/wasi-http https://github.com/WebAssembly/wasi-http WebAssembly (wasm) already runs in the browser, but now also it is being used to create cross-architecture executables and modules that might (so they say) replace k8s.
- euroderf 2y agoTo expand, as I understand it, the component model is meant to enable large scale deployment, and runtime module composition using well-defined interfaces in an IDL called WIT.
- gloosx 2y ago>htmx.ajax, htmx:trigger, synthetic load event >Nested shadow root >element is reinitialized via htmx.process() >Boosted <form> tags >htmx-powered elements located outside a form, but that refer to a form via the form attribute >preload, hx-boost, response-targets, ws, head-support, sse I see... Folks at HTMX are always thriving for a little bit more power of hypertext. Remember guys this is how S.I.M.P.L.I.C.I.T.Y. looks like. Fnatics, unleash your downvotes!
- ianpurton 2y agoDo some people have examples of interactivity they were able to replace with Htmx? For me, I've been able to get turbo style links with the boost to get nice page transitions. I can also see how I could use the class-tools extension to enable buttons to open dialogs etc. I'm curious to see when people say they needed an SPA for interactivity, what interactive features Htmx can already do and when do we need to break out some JS. An example that I think needs JS is a copy paste button.
- fhd2 2y agoOne thing I use HTMX for is to quickly hack interactivity into a more traditional site. One example is incremental filtering: I added an input field, and made it (a few ms after the last value change) load the same page the user is already on with a query parameter that filters the items in the response. Then I just replace the list of items with the contents from the response, ignoring the rest of the page. It's a bit wasteful perhaps, but all this took just a few lines of HTML.
- kisamoto 2y agoI tried HTMX but found it too restricting. It's great if you just want to load a portion of the page. Maybe if you have an up-vote, just send the request and replace the icon with a gold icon. But I want things like an on-site calculator. I load in products and prices, users can adjust sliders to change the quantity and relevant number is calculated. I don't want to use HTMX for this to call the server each time, I want instant reactivity and state in the frontend maintained so when the user has tweaked as necessary they can just check out. HTMX does not fit this use case so I use React to build widgets (or if even more complex SPA then Angular). If I'm using a JS framework anyway, then I don't need HTMX. It's just something else to clutter the project and remember to use. HTMX has its place but with the user expectation for reactivity in the browser I personally find it too limiting.
- halfcat 2y agoThis kind of use case is where you’d use Alpine instead of HTMX (if you’re going for the no-build approach). It has everything you’d need for this, client-side store, etc. Alpine is basically light weight, no-build Vue. HTMX is really only about swapping out the elements on the page and pushing updates to the server, which in this case might just be lazy loading the calculator component that contains Alpine attributes and Tailwind elements, and HTMX only if there are elements to swap or you need to save state to the server.
- 2-3-7-43-1807 2y agowhat is the selling point of htmx? why use it versus ...?
- halfcat 2y agoYou team knows Python/Ruby/PHP/Elixir/C# and uses Django/Rails/Laravel/Phoenix/ASP and doesn’t have a need to hire dedicated frontend people. You can leverage your existing talent to drive the frontend from the backend. It has limitations (not going to use HTMX to build Google Maps) but handles the 80% of use cases well for little added skillset required.
- recursivedoubts 2y agodepending on your application type it might simplify your application: https://htmx.org/essays/a-real-world-react-to-htmx-port/ https://htmx.org/essays/a-real-world-react-to-htmx-port/ how to determine if it is appropriate: https://htmx.org/essays/when-to-use-hypermedia/ https://htmx.org/essays/when-to-use-hypermedia/
- Babawomba 2y agoTried Htmx a while back... mixed feelings. Love how easy it is to get basic interactivity—honestly, adding a filter or an upvote button in a couple of lines of HTML feels like magic. No messing with a frontend framework, no bundlers - just works. But I hit walls when I needed more complex stuff. Like, if I want to keep state on the client (e.g., a live calculator or sliders updating a table), Htmx feels clunky. Sending a request to the server every time a user adjusts a slider—yeah, no. React or Svelte is a better fit there. And if you're already using those tools. Htmx starts to feel redundant. Why add more when you've got everything in one place? Also, not sure about the recent patch release - Changing default behavior in a minor update? Feels risky, even if it's "fixing a bug." Imagine waking up to find your body tag wiped because you updated without reading the changelog, yikes. Makes me think twice about trusting it in production. Butfor MPAs or projects that lean heavily on server-side rendering, it’s a game-changer. You’re not rebuilding the wheel, just enhancing it. Htmx has a sweet spot—it’s just not always the right tool for every job. Depends what you're building, I guess...
- adzm 2y agoSame here. I honestly love react, it just seems to make sense, integrates well with legacy stuff, great tooling, really nothing else comes close
- yawaramin 2y agoWait, why do I need React for a live calculator or sliders updating a table? Does plain JavaScript and the Web APIs no longer exist? Don't Web Components/custom elements exist? I need to immediately jump to React/Vue/etc. at the slightest bit of client-side interactivity? Also, do people just update and yeet their apps into prod without testing it? What happened to test environments? Test suites? Manual QA? Letting it soak? Where did quality control go?
- deleted 2y ago[deleted]
- htmxceo 2y agoI tried to use HTMX to fix some of the plumbing in our bathroom and I’m very disappointed … it just isn’t fit for purpose. I’m sticking with React
- halfcat 2y agoSame. Tried to write a boot loader in HTMX. Wish I’d used React instead.
- joshmanders 2y agoSame. Used htmx to write a pacemaker. Wish I'd used React instead. RIP dad, I miss you.
- qwm 2y agoI have several problems with htmx, and none of them are love of React or the thousands of NPM modules that make up most modern frontends today. I'm also not a fan of JavaScript itself, and I don't write Node backends unless I can't avoid it. The main problem I have with htmx is it requires my backend and frontend to be uncomfortably coupled. I write most of my backends in Go these days, but I've written a lot of Java and PHP in the past. I particularly hate PHP and the model of mixing backend logic and presentation markup. I'm not a fiend when it comes to separation of concerns; I try to keep relevant things together. With that said, constantly bundling markup with actions is annoying. For example, POSTing a comment would require the backend to send back the new comment's HTML, then possibly perform some action like bumping off comments that are too far down. The other big problem I have with htmx is that it has no good solution for managing state and staying consistent with the backend. I used to work on a site written in PHP that, while not using htmx, used generally the same system of returning HTML from ajax calls. I was working on implementing comment replies, which required not only appending a new comment, but changing some of the markup on the original comment to indicate that it had replies and a button to collapse those replies. The solution I chose for this was to make those changes to the original comment dynamically with raw JS, then append the HTML for the new comment returned by the server. This worked fine, but it was annoying because I had to replicate rendering logic in both JS and PHP. This kind of thing can easily become death by a thousand papercuts as your site grows and you have more and more duplicated rendering code. This problem does not exist in the Vue/React/etc. world. There is value in keeping all your rendering in one place, even if that place is the server and access to it requires enduring network latency. I understand why someone who uses a language other than JS for backend would enjoy htmx, but I think it's going to bite its users in the ass one day or another when their application becomes too big and rendering logic becomes hard to maintain. I would say my favorite alternative to htmx for people who want statically rendered pages but don't want to go without niceties like components, JS type checking, reactivity and other things that speed up frontend development and make it more scalable is Inertia.js. It allows you to use a JS frontend framework like Vue or Svelte and the backend of your choice without having to write an API or (god forbid) GraphQL. https://inertiajs.com/ https://inertiajs.com/ I've also found that petite-vue is great for adding progressive enhancement to otherwise static sites without using a bloated framework. I've used it in several contract projects and it works like a charm. https://github.com/vuejs/petite-vue https://github.com/vuejs/petite-vue