News for hackers. Stuff that matters.
Re:htmx 2.0.0-beta1 by ledgerdev on Sunday March 17, 2024 @01:36PM (#39736241)
I used htmx to build a now in production multi-step payment form that's currently in use by several hundred thousand people per month. It's been great, but not perfect and I would say a less well trodden path to get the edge cases right. I would absolutely say it's been a simpler overall solution for us as a small team than a full js client side framework would have been. Things that were hard to get right were setting up loading indicators, error display, keeping step/form state on browser history back/forward, tab sleep restoration after htmx navigation(especially tricky), and injection of third party form elements that had to be injected/remove and re-injected on back/forward between steps. I would be surprised if these sorts of edge cases weren't already handled by a popular js-frameworks but can't say for sure. The site load is very fast and we haven't even rolled out client side js validation on forms the server validation responds so fast. We are planning to use more htmx across other apps at present, so overall positive hypermedia for the win.
Re:htmx 2.0.0-beta1 by rasso on Sunday March 17, 2024 @03:38PM (#39737326)
I‘d also like to know what you mean by tab sleep restoration.
Re:htmx 2.0.0-beta1 by ledgerdev on Sunday March 17, 2024 @04:06PM (#39737560)
Re:htmx 2.0.0-beta1 by tomcam on Sunday March 17, 2024 @01:59PM (#39736465)
Super balanced & informative writeup, thank you. Can you tell me what you mean by tab sleep restoration?
Re:htmx 2.0.0-beta1 by ledgerdev on Sunday March 17, 2024 @04:05PM (#39737557)
Last year chrome started discarding background tabs to save memory, probably should have said discard rather then sleep it's been a while since I worked on that. Our user base keeps tabs in background often in mobile devices and we saw some reports of it. https://arstechnica.com/gadgets/2023/02/chrome-110-will-auto...

When you do an htmx navigation to a new page, a discarded tab will "restore" only the last htmx fragment loaded, not the entire html page with style tags. Fix is to use unique url on push that isn't in local cache which forces a server reload on tab wake from discard.

Re:htmx 2.0.0-beta1 by wmanley on Sunday March 17, 2024 @06:40PM (#39738702)
Try adding the response header:

    Vary: HX-Request
Re:htmx 2.0.0-beta1 by recursivedoubts on Monday March 18, 2024 @12:11PM (#39746369)
Yep, probably browser caching:

https://htmx.org/docs/#caching

Re:htmx 2.0.0-beta1 by ledgerdev on Monday March 18, 2024 @03:14PM (#39748651)
Next time I work on it, will try to see if that resolves it.
Re:htmx 2.0.0-beta1 by yawaramin on Monday March 18, 2024 @08:38PM (#39751772)
That worked for me. Thank you.