Comment by yawaramin
2 days ago
> How does "htmx sends a request header HX-Request: true with every request." happen without javascript?
It doesn't. If JavaScript is disabled, this header is not sent.
> you need a backend server that understands whatever this header is for the graceful fallback
Yes, as I mentioned in my blog post linked earlier: 'the backend server can use a fairly simple heuristic to figure out that it should respond with a fragment:...The request has a header HX-Request...The request does not have a header HX-History-Restore-Request...If these two conditions are fulfilled, it can respond with a fragment. Otherwise, it can respond with a full page ie <!DOCTYPE html>... and so on.'
> it wouldn't work with just nginx...
It would in a limited sense if you design the pages in a certain way and use the `hx-select` attribute: https://htmx.org/attributes/hx-select/
But...htmx is not really meant to work with just Nginx or other static web servers, it is meant to work with a BFF (backend-for-frontend) that specifically knows how to serve and handle the app in question.
From the criteria you have mentioned so far:
- Works without JavaScript
- Works with a static web server like Nginx
I can only conclude that you are talking about serving static sites with no dynamic interactivity. That's not really what htmx is about. Htmx is more like a simplified way to do SPA-like things.
> Htmx is more like a simplified way to do SPA-like things.
Okay. Then we agree. "Htmx is power tools for using Javascript to alter HTML".
With the implicit premise of starting from javascript you see that as "Power Tools for HTML". Without this premise I see it as "Power Tools for Javascript".
I think this distinction is not only important because I question the premise, but because many people who've talked to me about Htmx are confused about what Htmx is and believe that it works without javascript. This is not Htmx's fault, of course, but it could be made clearer by avoiding easily misinterpreted headlines like this.
> many people who've talked to me about Htmx are confused about what Htmx is and believe that it works without javascript
The htmx landing page's first paragraph says 'htmx gives you access to AJAX...'
AJAX stands for 'Asynchronous JavaScript And XML'.
Close below that, it has a 'quick start' section that shows how to install it, using a `<script>` tag.
For people who think it works without JavaScript, I am afraid they are facing deeper issues than htmx's tagline.