Delete Service Worker on Safari
To delete a service worker on Safari, you can follow these steps:
- Open Safari Developer Console (Press Command + Option + C)
- Copy and paste the following JavaScript code into the console:
1 2 3 4 5 6 7
| navigator.serviceWorker.getRegistrations().then(function (registrations) { for (let registration of registrations) { registration.unregister().then(function () { console.log("Service Worker Unregistered:", registration.scope) }) } })
|
This code will:
- Get all registered service workers using
navigator.serviceWorker.getRegistrations()
- Loop through each registration
- Unregister each service worker using the
unregister()
method
- Log a confirmation message with the scope of the unregistered service worker
You can verify that the service worker has been successfully removed by:
- Opening Safari Developer Tools
- Going to the Application tab
- Checking the Service Workers section - it should now be empty
Note: After unregistering the service worker, you might need to close all tabs and restart Safari for the changes to take full effect.