News for hackers. Stuff that matters.
Re:Htmx by candiddevmike on Wednesday December 14, 2022 @02:10PM (#33988490)
htmx keeps getting posted here and choosing it comes down to "do you trust that your user's internet is stable" IMO. For a lot of interactive web apps, the answer is no, and htmx is not a good fit.
Re:Htmx by qbasic_forever on Wednesday December 14, 2022 @02:19PM (#33988627)
I don't see why it couldn't be used in a PWA with a service worker providing offline HTML responses to hx directive elements though. You can see an example here that uses a WASM-based service worker (but you don't have to do that, it could just be plain old JS generating HTML): https://github.com/richardanaya/wasm-service
Re:Htmx by infogulch on Wednesday December 14, 2022 @03:52PM (#33990372)
Check out the live demo! https://richardanaya.github.io/wasm-service/

Last month I contributed the todos functionality to this project after it was submitted to HN. https://news.ycombinator.com/item?id=33228891

I think this is a great idea and could eventually enable htmx projects to transition from server-side-only to being a PWA with very little code changes (given the right backend).

Unfortunately this particular implementation exhibits some blocking issues which I was not able to solve yet:

1. The Service Worker is eventually unloaded from memory, which means all data is lost because it currently stores everything in memory. This isn't a defect as much as it is lacking a persistence feature; this is a MVP (emphasis on minimal) after all. The most promising solution in my opinion would be to use the OPFS/File System Access API with SQLite, which is yet to be shipped in all browsers.

2. The bigger issue is that once the SW is unloaded it doesn't come back. The SW getting reaped after being idle is fine, that's part of the expected behavior. But there are no events or any other indication that it was disconnected, at some point it just stops intercepting requests. I don't know why. If anyone can chip in here to say why it does this and how I can detect or somehow restart SW fetch interception on demand I would be glad to hear it.

( For some more detail see the "# Remaining Issues" in my PR #5: https://github.com/richardanaya/wasm-service/pull/5 )

Re:Htmx by jonomacd on Wednesday December 14, 2022 @02:19PM (#33988625)
SPAs make tons backend calls to get data. This isn't particularly different. To me the main difference is it is hard to build an offline app out of htmx as compared to a SPA but so few webapps are offline anyway...
Re:Htmx by Darmody on Wednesday December 14, 2022 @02:19PM (#33988642)
What does the internet stability have to do with htmx?
Re:Htmx by wild_egg on Wednesday December 14, 2022 @02:21PM (#33988668)
The creator himself calls out that htmx is not a good fit for highly interactive web apps

https://htmx.org/essays/when-to-use-hypermedia/