4 ms·
I do agree alot with the article. One of the major use case SPAs was optimization hack that service worker can do easily. Service worker are like proxy middlewa
by marcthe12 4y ago
I do agree alot with the article. One of the major use case SPAs was optimization hack that service worker can do easily. Service worker are like proxy middleware and are capable of some nifty tricks. Since I am not in web dev that much so I never actually managed to develop a project using it, but I felt that the templating could done fully in service worker. It will be faster as long the templating/transcompiling is not a bottleneck as the on wire format will be smaller. The main issue will be bootstrapping as you need to load a page first to install the service worker. I wonder if there is a good solution to that? (One idea is a service worker middleware on node so you can the service worker in the server side on first time use).
- nolanl 4y ago(Author here.) I totally agree and feel that Service Workers are still underexplored in this area. If your main reason for writing an SPA is speeding up navigation (e.g. the Turbolinks approach), then you may be better served by just moving the rendering logic into a Service Worker. It should be possible to build an "MPA" where all the rendering logic lives in the Service Worker. Then you'd get fast navigations without needing to worry about a client-side router and managing focus/scroll/etc. I'm not sure I've seen a great implementation of this though.
- keybits 4y agoHere’s a great example of how this can be done https://instantmultipageapp.com/ https://instantmultipageapp.com/
- nolanl 4y agoThank you! This is exactly what I had in mind. The streaming aspect of MPA pages is a great example of something you can't really do in an SPA. (Although there are hacks: https://jakearchibald.com/2016/fun-hacks-faster-content/ https://jakearchibald.com/2016/fun-hacks-faster-content/)