-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
offline support #893
Comments
This sounds like a perfect use case for a Single Page Application. You ship the HTML, one (or more with code-splitting) bundle of JavaScript and CSS and maybe a service worker. The app will talk to the API's directly or through the service worker. It's all there. Why bother using Fresh & the Island Architecture in a service worker? |
A Single Page Application (SPA) may certainly be more ideal than a Multiple Page Application (MPA) but either way being able to write the application with Deno rather than Node and avoid needing to use Webpack, etc. are the top things I'm looking for. One downside of a SPA is that larger apps suffer from high memory usage. I do not know of a way in JavaScript to remove code from memory once loaded (short of the ShadowRealm API which is currently a proposal in Stage 3). So even with code splitting once you move around the app and have loaded more and more bundles you're now consuming potentially a lot of memory. I'm not certain if this is the cause of some of the performance issues I've seen with apps I've worked in though. What I think would be ideal though is to define an app that runs on the edge (e.g. Deno Deploy) and then be able to reuse a bunch of that app's route code via a service worker. Fresh might not be the answer but it is the only Deno-based web UI framework that I know of with meaningful adoption. I could see a service worker dynamically loading whichever route code is needed when a request is made for a route or, if the app is small enough, keeping everything in memory more like code running on the edge. |
With regard to using Deno instead of node for developing your SPA I am setting this up in ccssmnn/relaxed-spa (demo: https://relaxed-spa.deno.dev) as a simple starting point. The goal is to develop client and server code in one Deno project with minimum boilerplate. It reuses the JIT client code bundling from fresh as well as the reloading mechanism on server restart. |
Something else that building the Fresh handler for offline usage gives over a SPA PWA solution is true dynamic routing and pages. With a SPA any data driven content has to be done during hydration whereas I want to minimize/reduce JavaScript in the document window and would prefer to fetch/load the data inside the service worker and then serve up to the document window dynamic content on demand. |
Closing as duplicate of #893 |
This is #893 @marvinhagemeister. Using something akin to Workbox.js feels more inline with Fresh than depending on an single-page application (SPA). This is the route I've been taking, but I'd like to see this as a recipe for Fresh to support real progressive isomorphic web applications, which Fresh seems well suited for. |
Whoops 😅 |
Closing as it's not something we're planning to do. |
I'd like to be able to use Fresh offline. My users are in rural areas throughout the day. Sometimes they have a strong internet connection and sometimes they do not. I want to bundle my entire Fresh app to run offline via a service worker. From what I can tell, the
handler()
in Fresh'sServiceContext
should be able to be used to take aRequest
from a service worker'sFetchEvent
and compute aResponse
. The esbuild runtime should be usable to bundle the service worker too (see also #858).The text was updated successfully, but these errors were encountered: