HTML has advanced in many ways over the last two decades, but it hasn’t grown much as a hypermedia. In particular, anchors and forms are still the primary way to drive network activity via user interactions in pure HTML-based applications.
The core idea is to use extended HTML attributes to drive server interactions, and allow for the replacement of elements within the DOM, rather than whole-page refreshes, based on HTML content returned from the server. This very much satisfies the REST constraints, and extends HTML as a hypertext (hence htmx).
The most significant attributes are:
- hx-get, etc. - specifies the url to issue a request too
- hx-trigger - specifies the event that triggers a request
- hx-target - specifies the element to update in the DOM
- hx-swap - specifies the manner in which the returned HTML content should be swapped into the DOM
Here is an example that demonstrates the “Live Search” pattern, using only a few attributes:
It seems to me that much of the functionality of htmx could, and perhaps should, simply be part of normal HTML. There is no reason a hypermedia should have to replace the entire document on navigation, and there is no reason why only clicks and submits should be able to drive network interactions.
The particulars of the htmx attributes don’t matter nearly as much as the general idea of revisiting HTML qua hypermedia and thinking about how we can drive it, and, therefore hypermedia-based application development, forward.