Skip to content

Instantly share code, notes, and snippets.

@erictherobot
Created August 2, 2022 14:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erictherobot/5778631a1fcc72d45d5c18f5359a0809 to your computer and use it in GitHub Desktop.
Save erictherobot/5778631a1fcc72d45d5c18f5359a0809 to your computer and use it in GitHub Desktop.
PWA Service Worker Register - DENO FRESH
// This is the service worker with the Advanced caching
// Add this below content to your HTML page inside a <script type="module"></script> tag, or add the js file to your page at the very top to register service worker
// If you get an error about not being able to import, double check that you have type="module" on your <script /> tag
/*
This code uses the pwa-update web component https://github.com/pwa-builder/pwa-update to register your service worker,
tell the user when there is an update available and let the user know when your PWA is ready to use offline.
*/
import "https://cdn.jsdelivr.net/npm/@pwabuilder/pwaupdate";
const el = document.createElement("pwa-update");
document.body.appendChild(el);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment