-
Notifications
You must be signed in to change notification settings - Fork 100
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
Only serve offline/error page if Offline Browsing is enabled; conditionally install service worker #436
Comments
@westonruter I did have a few queries regarding this task, It would be great if you can answer them.
|
This would essentially mean that the current Offline Browsing checkbox in Reading settings would be the opt-in to not only cache page navigations but also enable the offline page.
Basically there would be a helper function to see if there have been any registered SW scripts for a given scope.
We'd ignore the default scripts. So if only the default scripts are present, we'd skip installing the service worker since it wouldn't be doing anything. |
Since this is a more substantial change that may have unexpected behavior for users who previously have been passing the PWA check without enabling offline browsing, I'm going to punt this to 0.8 so we can think about it some more. |
As mentioned in #344 (comment):
This was not implemented in #365 but after thinking about it more, it seems the right way to go. Furthermore, the service worker should only ever be installed if there is any SW logic registered to run in it. So if the offline/error page is included with offline browsing, and offline browsing is not enabled, then there would be no SW logic registered and the SW should be skipped from being installed. As soon as that checkbox is enabled or if a plugin registers a script to run in the service worker, then the SW would then be installed automatically.
There probably needs to be a new conditional function added to check whether the SW is being installed.
By not installing the service worker by default, we'll avoid situations where the SW is responding to requests unexpectedly, which can cause confusion. It will also reduce extraneous SW installation across the web, reducing the service workers that are installed but aren't doing anything much of value.
The text was updated successfully, but these errors were encountered: