Install the service worker on your website

You will need to use a service worker on your website to use this feature. Copy-paste the line below, inside your service worker code loaded with the root scope.

This code should be dumped into your root service worker file in e.g wwwroot/service-worker.js

How to setup service workers (if not already done)

This assumes you have dumped your root service worker file to wwwroot/service-worker.js. Run this snippet of code with your website's javascript. The window.addEventListener("load", function () { code delay loads the service worker to ensure no performance metrics are affected. This can be removed for quicker initialisation.

This will only work on modern browsers like chrome, firefox and safari. The "serviceWorker" in navigator conditional will ensure no exceptions are thrown.