← Back
gatsby

Remove gatsby service workers

Unfortunately I've used Gatsby's offline plugin and now when I switch to Eleventy, it doesn't work.

As a quick fix, I've added this to the layout (source):


if (typeof window !== 'undefined' && 'serviceWorker' in navigator) {
window.navigator.serviceWorker.getRegistrations().then(registrations => {
registrations.forEach(r => r.unregister())
})
}

But it only works after reloading the page without cache (Cmd+R on Mac).

I guess there are no other option (since I didn't remove the plugin properly).


References and notes