Hacker News new | ask | show | jobs
by hruk 794 days ago
I've used HTMX quite frequently recently for internal frontends (admin pages, reporting, etc.). It's quite good.

A pattern I've been using a lot is not changing the backend at all - each endpoint still returns the full page. Each hypermedia control makes liberal use of hx-select and hx-select-oob to update the elements that may have changed.

This isn't super efficient, but it provides some "locality of behavior" in that you can look at a hypermedia control and know what other elements might be changed by it. It also means the backend doesn't really need to "know" about HTMX.

2 comments

Nice way to incrementally add capabilities to an existing app.

Back in the day, with Java JSP, there was a tag library called DisplayTag, which handled tables. It did a similar thing for in place paging, albeit a bit more brute force.

All JSP pages are buffered as they’re rendered. When the tag was rendered in “Ajax” mode, at the start of the tag it simply flushed the buffer, thus eliminating anything generated before, and at the end it simply aborted the remainder of the page. This effectively just returned the entire table element in isolation from the rest of the page.

It was a clever mechanic at the time.

That actually sounds OK. The lede seems buried in the docs, which focus on how it works not how to do what you want to do.