htmx 4 Released: Library Rebuilt with Modern fetch() API for Better Performance
By
leephillips
A five-star bake. Worth schmearing, sharing, saving.
Summary
The article announces htmx 4, a major update to the htmx JavaScript library that replaces its XMLHttpRequest-based implementation with the modern fetch() API. The author explains that while they previously committed to stability for htmx 3, the opportunity to rebuild with fetch() in fixi.js revealed significant advantages in performance, reliability, and modern web standards compatibility. The new version maintains backward compatibility while offering improved error handling, better support for streaming responses, and cleaner integration with modern web development practices. The author emphasizes that this is a foundational change that will enable future enhancements while preserving the library's core philosophy of HTML-centric web development.
Key quotes
· 5 pulledWe are going to work to ensure that htmx is extremely stable in both API & implementation. This means accepting and documenting the quirks of the current implementation.
Earlier this year, on a whim, I created fixi.js, a hyperminimalist implementation of the ideas in htmx. That work gave me a chance to get a lot more familiar with the fetch() API.
The fetch() API is simply better than XMLHttpRequest in every way that matters for htmx: it's more reliable, has better error handling, supports streaming responses natively, and is the modern standard for browser-based HTTP requests.
htmx 4 maintains full backward compatibility with htmx 3 while offering significant improvements under the hood. Your existing code should work without modification.
This change represents a foundational improvement that will enable us to build more powerful features on top of htmx while staying true to our philosophy of HTML-centric web development.
You might also wanna read
µJS: Lightweight AJAX Navigation Library for Instant Page Transitions
µJS is a lightweight JavaScript library that enables AJAX navigation for traditional websites without requiring a full framework. It interce
VMPrint: Pure JavaScript Library for Multi-Page Document Rendering and PDF/SVG Export
VMPrint is a pure JavaScript library for rendering multi-page documents that can be previewed on canvas and exported to PDF/SVG from the sam
htmx: Lightweight JavaScript Library for Modern HTML Development
htmx is a lightweight JavaScript library that enables developers to access modern web technologies like AJAX, CSS Transitions, WebSockets, a
HMPL.js: Lightweight JavaScript Template Language for Server-Driven Web Development
HMPL.js is a lightweight JavaScript template language designed for server-driven web development. It features block-based syntax, customizab
SVG.js: Lightweight JavaScript Library for SVG Manipulation and Animation
SVG.js is a lightweight JavaScript library for manipulating and animating SVG graphics. It has no dependencies and aims to be as small as po
Lit: A Lightweight JavaScript Library for Simplified Web Components Development
Lit is a lightweight JavaScript library that builds on Web Components standards to simplify web development. It provides reactivity, declara
