Technology
Htmx 4.0.0 released with migration to fetch API and explicit attribute inheritance
The major update transitions the library's internal networking and adjusts default behaviors for attribute inheritance and history tracking.
The short version
- The htmx development team has released htmx 4.0.0, the culmination of eight months of development.
- Key changes include migrating the library's internal networking from XMLHttpRequest to the fetch() API and standardizing event naming conventions.
- Attribute inheritance is now explicit by default, requiring developers to add an ':inherited' suffix to propagate attributes to child elements.
- The 4.0.0 release is flagged as 'next' on NPM to prevent breaking existing installations, with version 2.x remaining as the 'latest' designation until early 2027.
Key facts
- The htmx team released htmx 4.0.0 after eight months of development.[Hacker News]
- The library's internal networking has been migrated from XMLHttpRequest to the fetch() API.[Hacker News]
- Attribute inheritance is now explicit by default instead of implicit, requiring an ':inherited' suffix to apply parent attributes to child elements.[Hacker News]
- History support no longer caches pages in localStorage by default; instead, htmx re-fetches the page on back navigation, though a sessionStorage caching extension is available.[Hacker News]
- Htmx event names have been restructured to a standard 'htmx:phase:action[:sub-action]' format, removing XMLHttpRequest-specific events.[Hacker News]
- New features include built-in morph swaps and several new extensions, including 'hx-live' for front-end scripting.[Hacker News]
- Htmx 2.x will remain designated as 'latest' on NPM until early 2027 to protect users relying on unversioned CDN URLs, while htmx 4.0.0 will be flagged as 'next'.[Hacker News]
- The htmx team has provided a command-line upgrade tool and LLM guidance files to assist developers with migration.[Hacker News]
Sources
- Htmx 4.0.0 has been releasedHacker News