# 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.

Canonical: https://scaplet.com/glossary/service-worker

Glossary Glossary · Performance

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 with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fservice-worker%20(%22Service%20worker%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fservice-worker%20(%22Service%20worker%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fservice-worker%20(%22Service%20worker%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Fservice-worker%20(%22Service%20worker%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 3 minutes.

1. [What a service worker is 01](#what-a-service-worker-is)
2. [Requirements and lifecycle 02](#requirements-and-lifecycle)
3. [Register one 03](#register-one)
4. [Service worker vs web worker 04](#service-worker-vs-web-worker)
5. [What it means for SEO and speed 05](#what-it-means-for-seo-and-speed)

_01_Explained

## 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.

_02_At a glance

## Requirements and lifecycle

Service workers are only available in secure contexts, which means pages served over [HTTPS](/glossary/https). Browsers also treat http://localhost as secure so you can develop locally.

Stage

### Download

What happens

The browser downloads the service worker file when a user first visits a page it controls

Stage

### Install

What happens

An install event fires first. MDN says it can be used to start populating an IndexedDB and caching site assets

Stage

### Activate

What happens

Once installed, the worker receives an activate event, where it finishes setting up and can clean old caches

_03_Check 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: "/", }); }
```

_04_At 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.

_05_Explained

## 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](/glossary/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](/glossary/javascript-seo) setup and test the live page with Google's [URL Inspection tool](/glossary/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.

_01_ What 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.

_02_ Can I use a service worker without a PWA?

Yes. A service worker is a standalone browser API. [Progressive web apps](/glossary/progressive-web-app) use it, but you can register one on any HTTPS site.

_03_ Can service workers access the DOM?

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

_04_ Do 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. 01 [Service Worker API - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) developer.mozilla.org · checked 2026-10-25
2. 02 [Using Service Workers - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers) developer.mozilla.org · checked 2026-10-25
3. 03 [Using Web Workers - MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) developer.mozilla.org · checked 2026-10-25

## Keep learning

[All glossary](/glossary)

[Learn Progressive web app Performance](/glossary/progressive-web-app) [Related HTTPS Crawling and indexing](/glossary/https) [Read next Lazy loading Performance](/glossary/lazy-loading) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in glossary
[Server-side tagging](/glossary/server-side-tagging) [Service-area business](/glossary/service-area-business) [Session recording](/glossary/session-recording) [Share of voice](/glossary/share-of-voice)

More in Performance
[Lazy loading](/glossary/lazy-loading) [Lighthouse](/glossary/lighthouse) [Page experience](/glossary/page-experience) [Page speed](/glossary/page-speed) [PageSpeed Insights](/glossary/pagespeed-insights) [preconnect](/glossary/preconnect) [preload](/glossary/preload) [Progressive web app](/glossary/progressive-web-app) [Real user monitoring (RUM)](/glossary/real-user-monitoring) [Render-blocking](/glossary/render-blocking) [Responsive design](/glossary/responsive-design) [Responsive images](/glossary/responsive-images) [Service worker](/glossary/service-worker) [Speculation rules](/glossary/speculation-rules) [Speed Index](/glossary/speed-index) [SVG](/glossary/svg) [Synthetic monitoring](/glossary/synthetic-monitoring) [Time to First Byte (TTFB)](/glossary/time-to-first-byte) [Time to Interactive (TTI)](/glossary/time-to-interactive) [Total Blocking Time (TBT)](/glossary/total-blocking-time) [TTL (time to live)](/glossary/ttl) [Viewport meta tag](/glossary/viewport-meta-tag) [WebP](/glossary/webp) [AVIF](/glossary/avif)

Terms on this page
[HTTPS](/glossary/https) [Page speed](/glossary/page-speed) [JavaScript SEO](/glossary/javascript-seo) [URL Inspection tool](/glossary/url-inspection-tool) [Progressive web app](/glossary/progressive-web-app)

Free · 2 minutes

## Know the term. _Now check your site._

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

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **+212%** organic clicks in 90 days Ledgerly
