← Back to context

Comment by superkuh

2 days ago

Sure. There's that. But it doesn't progressively enhance. It doesn't even fail gracefully. It's just... nothing without JS. That's bad accessibility. For for-profit and institutional use cases that's fine. But if you're a human person and want to make a website that all human persons around the world can read, it's a bad fit.

That's incorrect. Htmx actually works really well with progressive enhancement, thanks to hx-boost. See https://dev.to/yawaramin/why-hx-boost-is-actually-the-most-i...

If you stick to GET and POST requests, you can ensure your app works almost exactly the same with or without JavaScript.

  • Thanks for pointing out a mitigation. I'm confused though. How does "htmx sends a request header HX-Request: true with every request." happen without javascript? And does this imply you need a backend server that understands whatever this header is for the graceful fallback? Ie, it wouldn't work with just nginx...

    • > 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.

      2 replies →