About this project
htmx is a compact, dependency-free JavaScript library that extends HTML with attributes for making HTTP requests and updating page content. According to its README, it provides access to AJAX, CSS Transitions, WebSockets and Server Sent Events directly in HTML, so developers can build modern user interfaces using the simplicity and power of hypertext.
The project describes itself as small, around 14k minified and gzipped, dependency-free and extendable. Its stated motivation is to remove arbitrary constraints in HTML: why only anchor and form elements should make HTTP requests, why only click and submit events should trigger them, why only GET and POST should be available, and why only the entire screen can be replaced. By addressing these, htmx aims to complete HTML as a hypertext system.
A quick start example shows including the library from a CDN and adding hx-post and hx-swap attributes to a button. The README explains that these attributes tell htmx to issue an AJAX request to a given URL when the button is clicked and replace the entire button with the response. htmx is presented as the successor to intercooler.js.
Installation is available through npm as htmx.org. The README notes an older broken package named htmx and clarifies the correct package name. Documentation and examples are hosted on the project website.
For contributors, the README outlines a hacking guide: install development dependencies with npm install, run a local web server such as npx serve, and open the test suite in a browser. Tests are organized under test directories for attributes, core functionality, regressions, extensions and manual cases. The project uses mocha, chai and sinon for testing and mocking AJAX requests. Contribution guidelines and sponsorship options are also referenced.
Comments
0 Rating appears after 10 ratings
Sign in to join the discussion.