htmx 4.0: Fetch-based rewrite, built-in morphing swaps, explicit attribute inheritance
The htmx team released version 4.0, the first major release since 2024, skipping version 3. The library switched from XMLHttpRequest to fetch(), added built-in morphing swaps based on idiomorph, the hx-partial tag, and explicit attribute inheritance via the :inherited suffix. Script size remains about 14 KB, and version 2.x is supported indefinitely.
- Switch from XMLHttpRequest to fetch() enables native streaming at ~14 KB
- Morphing swaps based on idiomorph preserve DOM state, including input focus
- Attributes inherit only with :inherited suffix — otherwise CSRF token breaks
- Events renamed to htmx:phase:action pattern, added 60-second request timeout
Read next
Software