diff --git a/package.json b/package.json index 2524aa55..7ad8930a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "js": "shx mkdir -p dist/_js && terser src/_js/main.js -cm -o dist/_js/main.js", "json": "json-minify src/.webmanifest > dist/.webmanifest", "xml": "minify-xml --in-place dist/sitemap.xml && minify-xml --in-place dist/blog.atom && minify-xml --in-place dist/features.atom", - "sw": "workbox injectManifest workbox-config.js && terser dist/sw.js -cm -o dist/sw.js", + "sw": "terser src/sw.js -cm -o dist/sw.js", "copy-img": "shx cp ./node_modules/@browser-logos/{chrome,firefox,node.js,safari}/*.svg src/_css/img/", "copy-js": "shx cp ./node_modules/dark-mode-toggle/dist/dark-mode-toggle.min.mjs dist/_js/dark-mode-toggle.mjs", "img-video-dimensions": "node add-image-and-video-dimensions.js", @@ -70,7 +70,6 @@ "postcss-custom-properties": "^13.0.0", "shx": "^0.3.4", "superstatic": "^9.0.0", - "terser": "^5.16.0", - "workbox-cli": "^4.3.1" + "terser": "^5.16.0" } } diff --git a/src/_js/main.js b/src/_js/main.js index ed04bfb7..ea778ae2 100644 --- a/src/_js/main.js +++ b/src/_js/main.js @@ -58,12 +58,9 @@ insertScript('https://platform.twitter.com/widgets.js'); } - // Install our service worker. - if ('serviceWorker' in navigator) { - addEventListener('load', () => { - navigator.serviceWorker.register('/sw.js'); - }); - } + // Remove any existing service worker + navigator.serviceWorker.getRegistrations().then( + registrations => registrations.forEach(each => each.unregister())); // Remove UTM garbage from URLs, to make it less likely such links get shared. if (location.search.indexOf('utm_source') > -1) { diff --git a/src/sw.js b/src/sw.js index daa2bfb0..1dd668b1 100644 --- a/src/sw.js +++ b/src/sw.js @@ -1,23 +1 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the “License”); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// . -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an “AS IS” BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.0.0-alpha.0/workbox-sw.js'); - -workbox.core.setCacheNameDetails({ - prefix: 'v8.dev', -}); - -// Note: this is populated at build time. -workbox.precaching.precacheAndRoute([]); - -workbox.skipWaiting(); +// Keep empty until some near future and then remove it. diff --git a/workbox-config.js b/workbox-config.js deleted file mode 100644 index b1d2da0c..00000000 --- a/workbox-config.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the “License”); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// . -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an “AS IS” BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -module.exports = { - globDirectory: 'dist/', - globPatterns: [ - '**/*.{css,mjs}', - '_img/v8-outline.svg', - ], - swDest: 'dist/sw.js', - swSrc: 'src/sw.js', - templatedURLs: { - '/': [ - 'index.html', - ], - }, -};