To implement this service worker in your project, you must copy the service-worker.js
file to the root directory of the webapp/web page. You must then amend your index.html
to contain the following script
tag:
<script>
// This makes sure that Service Workers are supported before registering.
if ('serviceWorker' in navigator) {
navigator.serviceWorker
.register('/service-worker.js')
.then((registration) => {