Skip to content

Commit

Permalink
Add javascript that unregisters all active service workers
Browse files Browse the repository at this point in the history
  • Loading branch information
katomm committed May 3, 2024
1 parent a255f38 commit bb46da0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ const config = {
},
],
}),

// Custom JavaScript that will be injected into the <head> section of every page
scripts: [
{
src: '/scripts/deactivateServiceWorker.js',
async: true
}
],
};

export default config;
12 changes: 12 additions & 0 deletions static/scripts/deactivateServiceWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// this script addresses https://github.com/cardano-foundation/cardano-org/issues/44
// it checks if the browser supports service workers and if it does, it retrieves
// all active service worker registrations and unregisters each one of them

if ('serviceWorker' in navigator) {
navigator.serviceWorker.getRegistrations().then(function(registrations) {
registrations.forEach(function(registration) {
registration.unregister();
});
});
}

0 comments on commit bb46da0

Please sign in to comment.