   waitForActivation(reg.installing || reg.waiting);
                } else if (!reg.active.scriptURL.endsWith(serviceWorkerVersion)) {
                    // When the app updates the serviceWorkerVersion changes, so we
                    // need to ask the service worker to update.
                    console.log("New service worker available.");
                    reg.update();
                    waitForActivation(reg.installing);
                } else {
                    // Existing service worker 