htmx 4.0 Ships — Morph Swaps, hx-partial, and a Cleaner Event System
htmx 4.0.0 dropped yesterday, and it's not a maintenance bump. This is a legitimate major version — breaking changes, genuinely new capabilities, and a rethought dev experience.
Two headline features:
Morph swaps built in. No more pulling in idiomorph as a separate dependency. The morphing algorithm has been improved and integrated directly into the core. If you've been doing smooth DOM transitions with hx-swap="morph" via extensions, this is now a first-class citizen. The upgrade path is simpler — the new swap strategy handles the edge cases that kept idiomorph out of htmx 2.x.
<hx-partial> tag. This rethinks how you compose responses. Out-of-band swaps worked, but they were always a leaky abstraction — you were swapping one element at a time and had to reason about the whole response. <hx-partial> lets you target multiple areas from a single response with crystal-clear intent. Think "I want to append a message to the chat log and update the unread count" — two targets, one response, zero ambiguity.
Beyond those: the event system was reorganized to a consistent htmx:phase:action[:sub-action] naming scheme (htmx:before:request instead of htmx:beforeRequest). Attribute inheritance got cleaned up — hx-disinherit is gone. There's a new docs site at four.htmx.org and an "LLMs" page with optimized docs for AI coding tools.
Verdict. htmx keeps earning its reputation as the library that respects HTML. v4 tightens the experience without expanding the surface area. If you build web apps and you've been on the fence about hypermedia, this is the version to try.