DEV Community

Damien Cosset
Damien Cosset

Posted on

Explain Service Workers like I'm five

Because Ben said they're coming to WebKit and Safari so...

Top comments (6)

Collapse
 
rapidnerd profile image
George

You go into a candy store, and chose your candy. Because you don't need to open the cash register or count the money the person behind the counter does it for you. While he's doing that you stare at other candy because you don't need to see it although sometimes we're interested to see it.

Basically a process that runs in the background of a browser that doesn't require your to do anything or have user interface.

Collapse
 
damcosset profile image
Damien Cosset

How are resources distributed between the background and the foreground? I'm not sure if this is a relevant question, but we fork something from the foreground, this means that something isn't available anymore?

What is the tradeoff in using a service worker? I gain something by letting someone else handle the cash register, but what am I losing?

Collapse
 
nektro profile image
Meghan (she/her)

Service Workers are a JavaScript based proxy written by the devs of PWAs that allow the programmatic control of the cache of your site/origin and are the main driving force in giving web developers the ability to make your websites available offline.

Some more great resources to get started:

Collapse
 
rkichenama profile image
Richard Kichenama

You are driving a car on a highway, focused on traffic around you. There is music playing on the radio you turned on when you started the car. While driving, you hear different songs, but are not actively selecting any of them. You hear a song you do not like, so you change the radio station.

You driving the car is the main web page and the service worker is the radio. When you start the car, the worker can begin and continues working without your interaction. When you change the station, you are effectively sending a message to the worker to do work, and the result is a different stream of music in the car.

Collapse
 
timothymehlhorn profile image
Tim Mehlhorn
Collapse
 
vinuverma profile image
vinuverma • Edited

Really an awesome post by Mariko!