Loading
A script that sits between your web app and the network, letting your site work offline by caching files — like a librarian who keeps copies of popular books so you don't have to order them every time.
A type of web worker that intercepts network requests via the fetch event and can serve cached responses, enabling offline support, background sync, and push notifications. Service workers have a distinct lifecycle: install, activate, and idle.
Service workers operate as event-driven proxies registered per scope. The install event pre-caches assets; the activate event cleans stale caches. The fetch event intercepts all in-scope requests, enabling cache-first, network-first, or stale-while-revalidate strategies. Updates follow a byte-for-byte diff check; the new worker enters 'waiting' until all controlled clients close or skipWaiting() is called.