Remix.run Logo
ndr 4 days ago

If you never seen HTMX it is a small js library that lets you swap some part of your dom with the responses from your webserver.

This means that in theory you (as a dev) don't need (to write any) js, nor do your users need to download a full page (for any interaction) like it's 1999. Your webserver replies with fully server-renderd HTML but just for the dom node (say a div) that you want to replace.

It's fun for very simple things, even great for extremely simple interactions modes. For interactive products, anything beyond simple CRUDs, it's madness.

Whenever you want to sprinkle a tiny bit of interactivity you'll have to choose between the path of least resistance (a small hack on HTMX) or a proper way. State management gets out of control real fast, it's the opposite of UI=f(state).

I've seen it go bad, then worse with alpine-js, and then completely ripped in favor of something where people can let the browser do browser things.

[edit for clarity]

rkomorn 4 days ago | parent | next [-]

> it is a small js library ... This means that in theory you don't need js

I assume I'm not the only person left a little puzzled.

Do you mean "don't need JS" as in like, a full-fledged JS framework?

ndr 4 days ago | parent | next [-]

See the quickstart from htmx.org

    <script src="https://cdn.jsdelivr.net/npm/htmx.org@2.0.8/dist/htmx.min.js"></script>
      <!-- have a button POST a click via AJAX -->
      <button hx-post="/clicked" hx-swap="outerHTML">
        Click Me
      </button>

When the user clicks the button the browser will take the result of the request to `/clicked` and swap the whole button dom node for whatever the server sent.

As a dev you get to write HTML, and need to learn about some new tag attributes.

Your browser is still running js.

lunar_mycroft 4 days ago | parent | prev | next [-]

They mean that you don't need to write JS, you can just add a script tag to your page

chamomeal 4 days ago | parent | prev [-]

Sorry I know other people have responded already, but it means you don't have to write any client side javascript at all. You can just skip along with a server that returns html. Just throw the script tag in there, and you're done.

The magic of this is that it's pretty easy to make SPA-like webapps with no javascript or complex client side framework. You can write your server in python, rust, clojure, whatever. If you don't need a lot of state management, it's really simple and awesome.

bmacho 4 days ago | parent | prev [-]

> If you never seen HTMX it is a small js library that lets you swap some part of your dom with the responses from your webserver.

> This means that in theory you don't need js, nor do your users need to download a full page like it's 1999. Your webserver replies with fully server-renderd HTML but just for the dom node (say a div) that you want to replace.

You got this backwards. With HTMX you need js. But just to swap a div, you can use link target + iframe, like it's 1999.

ndr 4 days ago | parent [-]

You [as a dev] don't need [to write] js.

Your browser will still run js. See sibling thread.