Work beside the page

A web worker can do a time-consuming calculation without freezing the visible page. It sends results back to the page when ready. It does not directly change what is displayed.

A service worker has a different job. It can sit between a website and the network, helping save files in a cache and serve them when the connection is poor. That can support offline features in a progressive web app. Its lifetime is controlled by the browser, so a site cannot rely on it running constantly in the background.