Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable service workers #760

Merged
merged 8 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
camillobruni marked this conversation as resolved.
Show resolved Hide resolved
"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",
Expand Down Expand Up @@ -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"
}
}
9 changes: 3 additions & 6 deletions src/_js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 1 addition & 23 deletions src/sw.js
Original file line number Diff line number Diff line change
@@ -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
// <https://apache.org/licenses/LICENSE-2.0>.
//
// 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.
27 changes: 0 additions & 27 deletions workbox-config.js

This file was deleted.

Loading