Htmx 4.0 ships with fetch() and morphing swaps

Htmx 4.0 is officially out, continuing its crusade against complex JavaScript frameworks with a fresh engine and cleaner defaults.

The htmx team released version 4.0.0 after eight months of development. Under the hood, the library ditched XMLHttpRequest for the modern fetch() API. From the outside, it works almost like version 2, but it introduces explicit attribute inheritance, standardized event names, and built-in morph swaps.

Why it matters: You get cleaner DOM updates and fewer history bugs without adding heavy build steps. By dropping localStorage page snapshots during back navigation, third-party scripts no longer break when users click the back button.

Here's the gist on upgrading: attributes no longer inherit automatically down the element tree. You now add :inherited to parent tags, or run the team's new command-line tool to flag old code and event listeners. If you use NPM, version 2.x remains the latest package until 2027 to avoid breaking unversioned CDN links.

Your single-page app framework might need another rewrite, but your HTML just got a lot smarter.