Free auditStart free
GlossaryGlossary · Performance

Service worker

A service worker is a script that sits between a web app, the browser and the network. See the lifecycle, HTTPS rule, registration code and the SEO caveat.

3 min
read
3
sources
Oct 21, 2026
updated
Scaplet Editorial Team
author
In one line

A service worker is a JavaScript worker that acts as a proxy between a web app, the browser and the network. MDN says it can enable offline experiences and intercept network requests. It needs HTTPS (localhost is allowed), has no DOM access, and moves through download, install and activate.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Explained

What a service worker is

MDN describes service workers as acting "as proxy servers that sit between web applications, the browser, and the network (when available)." They are intended, among other things, "to enable the creation of effective offline experiences, intercept network requests, and take appropriate action based on whether the network is available, and update assets residing on the server."

A service worker is a type of web worker. It runs in a worker context: it has no DOM access, runs on a different thread from your page's JavaScript, and is designed to be fully asynchronous.

03Check it

Register one

The scope option is optional and sets which part of your content the worker controls. With "/" it controls all content under the origin. By default, MDN says, the scope is the directory where the worker file is located. To ship an update, give the new version its own cache name in the install event and delete old caches in activate, as MDN's guide shows.

From MDN: register with feature detection
if ("serviceWorker" in navigator) {
  const registration = await navigator.serviceWorker.register("/sw.js", {
    scope: "/",
  });
}
04At a glance

Service worker vs web worker

Purpose

Web worker
Run scripts in a background thread without interfering with the user interface
Service worker
Sit between page and network, handle requests

DOM access

Web worker
None
Service worker
None

Runs in a worker context

Web worker
Yes
Service worker
Yes

MDN says a service worker is a type of web worker, so the two share the no-DOM, separate-thread model. A service worker also has no access to synchronous XHR or Web Storage.

05Explained

What it means for SEO and speed

A service worker can answer requests from a cache, which is how it supports offline use and can help page speed for returning visitors. It runs in the visitor's browser, so if a page's content depends on it, review your JavaScript SEO setup and test the live page with Google's URL Inspection tool. When you ship an update, version your cache names and delete old caches in activate, as MDN's guide shows.
Questions

Asked a lot.

4 questions people ask next, answered from the sources on this page.

01What does the term service worker mean?

A script your browser runs in a worker context that sits between your web app and the network, so it can cache files and handle requests, including when the network is unavailable.

02Can I use a service worker without a PWA?

Yes. A service worker is a standalone browser API. Progressive web apps use it, but you can register one on any HTTPS site.

03Can service workers access the DOM?

No. They run in a worker context on a different thread and have no DOM access.

04Do service workers need HTTPS?

Yes, they are only available in secure contexts. Browsers also allow localhost for development.

Sources · 3

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • mozilla.org
  1. 01Service Worker API - MDN Web Docsdeveloper.mozilla.org · checked 2026-10-25
  2. 02Using Service Workers - MDN Web Docsdeveloper.mozilla.org · checked 2026-10-25
  3. 03Using Web Workers - MDN Web Docsdeveloper.mozilla.org · checked 2026-10-25
Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly