Web APIs
ServiceWorkerContainer.prototype.ready
Promise resolving to a registration with an active service worker for the associated page. It does not guarantee the current page has a controller.
Formal Syntax & Structure
javascript syntaxjavascript
navigator.serviceWorker.readyWorking Example
Example Snippetjavascript
(async () => {await navigator.serviceWorker.register("./sw.js");const r=await navigator.serviceWorker.ready;console.log(Boolean(r.active));})()