Making my site work offline had been on my bucket list for a while. It was the last thing in Google Chrome’s Lighthouse test to complete. The site now has close to 100 scores across all areas in Google Chrome’s Lighthouse Audit.

I read up on Service Workers on both Google Developers and MDN Web Docs.

I then read this article which helped me create my service worker.

I initially put my service worker in my JavaScript subdirectory, which didn’t work. I then realized that the Service Worker has to be put in the root directory of the website to allow it to control the scope of the website.

You can view the code I used in this repo on GitHub.