Skip to content

Instantly share code, notes, and snippets.

@yoruponder
Created February 6, 2018 03:57
Show Gist options
  • Select an option

  • Save yoruponder/d435c8525d4f1cfd73c257049101a232 to your computer and use it in GitHub Desktop.

Select an option

Save yoruponder/d435c8525d4f1cfd73c257049101a232 to your computer and use it in GitHub Desktop.

Revisions

  1. yoruponder created this gist Feb 6, 2018.
    17 changes: 17 additions & 0 deletions unregistersw.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    navigator.serviceWorker.getRegistrations().then(function (registrations) {
    if (!registrations.length) {
    console.log('No serviceWorker registrations found.')
    return
    }
    for(let registration of registrations) {
    registration.unregister().then(function (boolean) {
    console.log(
    (boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' +
    (registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') +
    (registration.waiting ? ' .waiting.scriptURL = ' + registration.waiting.scriptURL + '\n' : '') +
    (registration.active ? ' .active.scriptURL = ' + registration.active.scriptURL + '\n' : '') +
    ' .scope: ' + registration.scope + '\n'
    )
    })
    }
    })