Htmx 2.0 released, aims to replace complex JavaScript frameworks with easily understood HTML attributes 

Htmx 2.0 released, aims to replace complex JavaScript frameworks with easily understood HTML attributes 

The Htmx project to extend HTML has released version 2.0, the first major version since 1.0 in November 2020.

Htmx 2.0 removes support for Internet Explorer, moves extensions out of the core repository so that each extension can be released according to its own cadence, removes deprecated attributes, and changes HTTP DELETE requests to use parameters rather than form encoded values. 

There are also new features including an htmx.swap() method that replaces existing content with new content. This replaces and improves on the existing internal selectAndSwap() method. There is also improved integration with web components, reusable custom elements.

The release post explains that to avoid breaking existing projects, the 1.x version will remain as “latest” in NPM (Node Package Manager) and 2.x as “next” until January 1st 2025. Migration to version 2.0 is not difficult but may require some work according to the migration guide.

Htmx is an alternative approach to front-end development focused on HTML rather than JavaScript (though it is implemented as a JavaScript library). Htmx evolved from a previous project called intercooler.js, also created by Htmx inventor Carson Gross, which dates back to 2013. Both projects are inspired by the idea that the power of HTML has been limited by the focus on JavaScript frameworks, the complexity of which has tended to increase. “HTML-oriented web development was abandoned not because hypertext was a bad idea, but rather because HTML didn’t have sufficient expressive power. htmx aims to fix that & allows you to implement many common modern web UI patterns using the original hypertext model of the web,” wrote Gross when introducing version 1.0 in 2020.

Htmx now supports features including asynchronous requests, CSS transitions and WebSocket communications using HTML attributes.

Although Htmx remains less well-known than frameworks like React or Angular, it is appreciated by developers. “I was pulling my hair out trying to figure out which js framework was less of an overkill, and finding htmx was pure joy” said one yesterday. Another said that “HTMX is simply wonderful. Using it for a major project as we speak.”

Gross participated in a Hacker News discussion and answered questions. Are there any efforts to push Htmx functionality into the HTML standard? “We are talking with the Chrome developers about these ideas, I’m cautiously optimistic,” said Gross.

Htmx uses XMLHttpRequest rather than the newer and more powerful fetch API. Has the team looked at using fetch instead? “Looked at it, unfortunately fetch() and xhr have a non-intersecting set of features (in particular, upload progress for xhr) so we decided not to touch it,” Gross replied.

The project is open source on GitHub under the Zero-Clause BSD license.