142 points · by mxbck · 9y ago · 63 comments
A PWA does not equal push notifications. Those are completely optional and should of course only be added where that makes sense. And even then, you'd have to agree to receiving them first.
> ...or ability to visit your website offline
Fine, you don't have to. In that case, the service worker just improves page speed and reduces data usage.
Hmm, how does it do that? I don't see what advantages it may have over caching and HTTP/2 push...
EDIT: still talking about regular websites? First visit or repeated visit? Most website already can take advantage of plain browser caching and service worker is IMO hard to sell here.
For example if you visit the admin login page, it can trigger a fetch of the assets for the admin page, then stuff them in its own cache.
Also a service worker would add additional process in Chrome and require 30-40 Mb of RAM. I don't want service workers in my browser.
Well, web standards have always been this broken and illogical as long as I rememeber.
Chrome debug tools work just fine.
> How to see if any of your visitors cannot load site because of error in a service worker?
The service worker fetch event is a promise, so you can catch any errors encountered and tell the client to go fetch the remote version instead. You can then do whatever analytics stuff you want with the error.
> How to decide which pages to preload for offline reading?
Well, who knows. But it's flexible enough to let you decide yourself - the last attempt, AppCache, forced you to decide upfront. With a service worker you could in theory use a user's browsing history to know what pages they are likely to look at. Or you can actually create responses manually in the worker, so you can dynamically generate an entire page locally on the device. It's very powerful.
> Also a service worker would add additional process in Chrome and require 30-40 Mb of RAM
This part I can't argue with. I mean, Chrome already uses a different process for every tab, but more resources is more resources.
I don't see service workers as over engineering, I see them as a low level API. We just need some abstractions.
> The service worker fetch event is a promise,
By the way promises is another poorly designed technology: they catch unhandled errors and do not report them in any standard way [1].
[1] https://stackoverflow.com/questions/28001722/how-to-catch-un...
Why is that a problem?
> By the way promises is another poorly designed technology: they catch unhandled errors and do not report them in any standard way
If you're using promises there is really no reason to not be handling your errors. Catching unhandled errors is by design and it works great. It's absolutely trivial to do.
And, as the SO post you've linked to points out, you can catch unhandled promise errors using window.onunhandledrejection. It's not like it's that dramatically different to window.onerror. Promises might not be perfect, but they're better than JS callback hell in absolutely every way.
But I am somewhat skeptical of the implications beyond SPAs, which is that, across the entire Internet, basically every static website in the world should be converted to a PWA for an optimal mobile experience. Doesn't that seem backwards? Shouldn't mobile browsers have a way to "just work" and give a great experience for static websites, rather than changing all the sites? Shouldn't we only need something like PWA for rich SPAs?
A news site might see huge value in implementing push notifications, whereas a shopping site might not. Messaging sites may see huge value in background sync, but it will be of little value to others. So on, and so forth.
My main complaint is that the biggest win for PWAs is simple caching - you can explicitly choose which resources to add to a cache instead of relying on the normal browser cache. This becomes necessary on mobile because the browser cache is very small and is emptied far too often - I'd rather them solve that problem before forcing everyone to make a service worker just to ensure their CSS and JS is cached successfully.
HTTPS or Service Worker caching is not something a mobile browser can do for you by default.
Consider it a suggestion to developers who are tempted to implement cool new tech on a site just to tickle their own itch.
> The Pentium III processor's Internet Streaming SIMD Extensions Instruction Set has been a hit with software developers resulting in numerous optimized Web sites and software applications available today.
[0]: https://www.intel.com/pressroom/archive/releases/1999/dp0517...
And you're ignoring huge benefits like offline availability, push notifications, storage...
Good news is that a service worker can't do that. It gets automatically shut down after a short period of time. It will be woken up again in response to push notifications, which you must request permission for, or in response to a new user event.
> Maybe my users pay for their data, or maybe they have a poor connection.
Which is why providing greater offline capability is a good thing, not a bad thing.
"Application" in PWA is best thought of as indicating the user experience on a mobile, with the ability to add to homescreen without downloading via an app store, and offline capabilities. Where PWA shines is website > AMP > PWA. See https://www.google.com/search?q=myntra+kurtis on your mobile for a great example of this transition.
For personal static blog, it doesn't take any effort to be fast; just don't bundle lots of bs stuff with it.
btw, there are still optimizations that can be done for author's site. See Google PageSpeed
https://developers.google.com/speed/pagespeed/insights/?url=...
Make it too long and you may have trouble to find the next line. Make it too short and your eyes will suffer from traveling back too often.
When I come upon a site that uses too much horizontal space for me to read comfortably, I just leave.
I have a PWA that creates html/css in the build process. If JS is enabled, it acts as an SPA. If JS is disabled, it's a simple static site. If ServiceWorker can be used, caches the html/css I built which both the SPA and static site versions can use. If no SW, then fallback to AppCache/LocalStorage/etc.
The hardest part was finding a CSS framework that doesn't use JS and still can do menus/etc nicely.