4 ms·
Wonder if there is there anybody who is making an offline app with request-reponse with html(with HTMX) and a virtual server defined in a service worker?
by aitchnyu 3y ago
Wonder if there is there anybody who is making an offline app with request-reponse with html(with HTMX) and a virtual server defined in a service worker?
- nymanjon 3y agoYes, here is one. https://github.com/jon49/htmx-todomvc https://github.com/jon49/htmx-todomvc I use this pattern for all my personal apps. I use my own little htmx-like library though. But wouldn't be that hard to swap in HTMX.
- jonahx 3y agoThis is a great question. I love htmx but in situations that have to work offline I can't use it. Would be a great hack to be able to just run your server code in a worker.
- WA 3y ago> Would be a great hack to be able to just run your server code in a worker. This is exactly why some people build heavy offline-first SPAs in JS. HTMX tries to avoid this entirely. Conceptually (seen from the perspective of HTMX), it makes zero sense to put the server code in a worker and run a client-server architecture in the client‘s browser. This would be an over-engineered thing that HTMX explicitly tries to avoid in the first place.
- nymanjon 3y agoI made an app doing this with an HTMX-like library with a total of 100 kB minified/zipped code. Not bloated at all. The code to make it work is about 10 kB. The rest is the code for the actual app.
- gedy 3y ago> This would be an over-engineered thing that HTMX explicitly tries to avoid in the first place. Yes, this is where I think a lot of folks who moan about "bloated JS frameworks", etc. really are just complaining they can't use their favorite (or only) language for web UI development.
- naasking 3y agoI'm not sure "zero sense" is true. An app designed around REST and hypermedia imposes sensible constraints, like how you handle state, navigation, etc., and this can still yield plenty of benefits.
- nymanjon 3y agoYes, I've done this and the code is really simple to understand compared to a SPA. https://github.com/jon49/Soccer https://github.com/jon49/Soccer
- datadeft 3y agoI am not sure if I understand the definition of offline here. HTMX has graceful degradation options. What else could you do when the client is offline?
- thisgoesnowhere 3y agoThere are many apps that work when the user is entirely offline and HTMX is not a good option if that is a key requirement of your app. Figma is an example.
- mozey 3y agoI'm working on a server/backend for htmx that's intended to run as a local service beside the browser. In theory you could do this with any server stack that is self host-able. My goal is to produce a single binary with no external service dependancies. I'm using Go, and a lot of the components are readily available, e.g. self updating local service, replicated database, etc. It's easy to cross-compile for different target OS and architectures. As an alternative to building everything into the browser, and assuming you're able to run a separate process, this approach makes a lot of sense to me. It would be great if Go had something similar to Deno's permission management though...