Skip to content
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

Prevent preload while website is offline #73

Open
ghost opened this issue May 23, 2020 · 1 comment
Open

Prevent preload while website is offline #73

ghost opened this issue May 23, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented May 23, 2020

Issue

I use instantpage.js on my blog that has a service-worker to implement offline functionality. In case a user accesses my website offline I receive a net::ERR_INTERNET_DISCONNECTED error in the preload function when instantpage.js tries to prefetch a resource.

Expected

As a website owner, I want to only prefetch URLs when I am online, so that I am not getting network errors when my site is offline or served by a service-worker.

Potential solution

To show a potential solution I created a pull request that implements a guard in the preload function to disable preload when the navigator is offline (https://developer.mozilla.org/de/docs/Web/API/NavigatorOnLine/onLine). I don't know if it is be possible to prefetch directly from the service-worker cache in this case, but I guess prefetching only makes sense when you are online anyway (of caused to be discussed!).

I am a part time developer so the adjustment should be deeply checked and tested!


KR and thanks for making and maintaining this awesome script!

@ghost
Copy link
Author

ghost commented May 23, 2020

Sorry, I am new to pull requests so I created one on my fork and then another directly on this repository!

@dieulot dieulot added the enhancement New feature or request label Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant