3 ms·
Is this actually a reasonable scenario for using HTMX? Is JavaScript even required?
by schemescape 4y ago
Is this actually a reasonable scenario for using HTMX? Is JavaScript even required?
- schemescape 4y agoAnswering my own question, you can make an element appear using just CSS and a hash: https://enmascript.com/articles/2019/09/26/toggle-content-on-click-without-javascript https://enmascript.com/articles/2019/09/26/toggle-content-on... I don’t like messing with the URL to achieve this, so unless using the “details” element, maybe JavaScript is actually the best approach…
- Dauros 4y agoHTMX is basically a JavaScript framework that makes the traditional request-response approach feels like an SPA via replacing only part(s) of the current page with the response. In this case: it loads a small form, submits it to the backend, then replaces the respective part of the page with the updated markup. The state is kept only at the backend. With some constraints you can create a page that works with or without JS. The same endpoint can be used for serving HTML fragments for HTMX and full page for JS-disabled clients since the HTMX request can be detected by the HX-Request header.
- CRConrad 4y ago> ...basically a JavaScript framework that makes the traditional request-response approach feels like an SPA via replacing only part(s) of the current page with the response. Didn't that used to be called AJAX or REST or something?
- Dauros 4y agoYes! HTMX is a better API on top of a XMLHttpRequest for this approach. A hypothetical next iteration of the HTML standard could make most of HTMX unnecessary. Maybe one day.