プロジェクト
概要
ウェブサイトから ServiceWorker を削除するためのコードスニペットとガイドです。
学習・教育計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルSelf-destroying ServiceWorker
Code-snippets and guides on removing ServiceWorker from a websiste.
Motivation
ServiceWorker is more and more often used in websites development. It’s being added to popular tools and libraries. Sometimes, it might be used unintentionally (generated by a pre-configured tool automatically) or for experimental purposes. This leads to a situation where ServiceWorker needs to be removed.
How to use
- Remove everything about your previous ServiceWorker (registration/uninstallation code, ServiceWorker file)
- Create a file with the same name as your previous ServiceWorker and put it in the same place where your previous ServiceWorker was
- Put following code into the file:
self.addEventListener('install', function(e) {
self.skipWaiting();
});
self.addEventListener('activate', function(e) {
self.registration.unregister()
.then(function() {
return self.clients.matchAll();
})
.then(function(clients) {
clients.forEach(client => client.navigate(client.url))
});
});
- Deploy your project! 🎉
License
MIT
関連プロジェクトを探す
読み込み中…