Hasty Briefsbeta

Changes in htmx 4.0

5 days ago
  • #javascript
  • #web-development
  • #htmx
  • htmx 4.0 is a complete rewrite using the fetch() API, replacing XMLHttpRequest.
  • Explicit attribute inheritance is now the default, using the `:inherited` modifier.
  • Event naming convention changed to `htmx:phase:action[:sub-action]` for consistency.
  • History storage no longer uses `localStorage`; full page refresh on navigation.
  • Non-200 responses now swap by default, except for 204 and 304 status codes.
  • New morphing swap styles (`innerMorph`, `outerMorph`) for better DOM state preservation.
  • Built-in streaming response support with improved SSE handling.
  • View Transitions API enabled by default for animated DOM state transitions.
  • New scripting API for better async/await support and custom JavaScript integration.
  • Unified request context (`ctx` object) for consistent event handling.
  • Modern swap terminology introduced (`before`, `after`, `prepend`, `append`).
  • New `:append` modifier for attribute inheritance to append values.
  • HTTP status code conditional swapping with `hx-status:XXX` attribute.
  • New `<hx-partial>` tag for multiple targeted swaps in a single response.
  • Several attributes renamed or removed, with new attributes like `hx-action` and `hx-method`.
  • Event names updated for consistency; new events added for better lifecycle handling.
  • Extensions now globally registered, no longer requiring `hx-ext` attribute.