W3C home > Mailing lists > Public > public-digipub-ig@w3.org > May 2015

RE: Notes on Web and Service Workers

From: Bill Kasdorf <bkasdorf@apexcovantage.com>
Date: Tue, 12 May 2015 15:54:47 +0000
To: Nick Ruffilo <nickruffilo@gmail.com>, Ivan Herman <ivan@w3.org>
CC: Tzviya - Hoboken Siegman <tsiegman@wiley.com>, Markus Gylling <markus.gylling@gmail.com>, W3C Digital Publishing IG <public-digipub-ig@w3.org>
Message-ID: <CO2PR06MB572EEB8881B960021B02B71DFDA0@CO2PR06MB572.namprd06.prod.outlook.com>
Nick, were you a teacher in a past life? ;-)
--Bill K

From: Nick Ruffilo [mailto:nickruffilo@gmail.com]
Sent: Tuesday, May 12, 2015 10:16 AM
To: Ivan Herman
Cc: Tzviya - Hoboken Siegman; Markus Gylling; W3C Digital Publishing IG
Subject: Re: Notes on Web and Service Workers


Web/Service workers can be some seriously complex topics, especially if you don't come from a computer science/linux background, but I'll try to explain them in completely "human" terms.

Imagine your web page - instead of being a bunch of HTML/CSS/Javascript, being a person - lets say ME.  (obviously this is a bit of a simplification, but you'll get the point) When you first access that website, I create outlines for the objects based on the HTML code.  Then, I paint and manipulate how those objects based on the way they look (that's the CSS).  I'm one person, so I can only do one thing at a time.

Next, once everything is laid down, I get to "work" (javascript).  As your mouse moves I check my list of instructions to see if I should be triggering an interaction, etc.  But I'm only 1 person.  Technically you can have me complete multiple tasks (have a clock that displays the time, play an animation, etc) but, for the most part, I have to figure out how to manage all of that with my arms and legs.

In comes "Web/Service workers."  Lets say I'm getting really tired, I can call a "Web Worker" (temporary labor) to come handle some tasks for me.  Since this is a new person, they can handle the tasks independent of what I am doing.  Since a web-worker is temporary labor, they will go away as soon as you close that page.

Then we get into Service Workers.  Service workers are like butlers - they stick around even if you leave the page.  So, if you ask them to make you a sandwich (because you're so hungry from running so much javascript) the user can close the page, then come back later, and the butler is ready with the sandwich.

Ultimately it comes down to THREADs.  A thread is a "line" of functions.  Most of programming is linear: Execute this code, then move on to the next.  Repeat.  The issue is that if one task takes a long time, everything AFTER that gets delayed.  Creating a 2nd thread means work can still get done.  Today's chips can easily handle multi-threaded operations and excel at it.  Web workers are a way to easily define threads, whereas in the past you had to do it in a very "hacky" way using timers (in javascript).

Hopefully this clears things up.  If anyone spots a flub by my explanation, please let me know!

On Tue, May 12, 2015 at 8:24 AM, Ivan Herman <ivan@w3.org<mailto:ivan@w3.org>> wrote:
Tzviya, Markus,

I have spent some time trying to get *some* idea on what Web Workers and Service Workers are. They are spinning my head and I am sure there are many details that I simply did not understand. Nevertheless, I thought it is worthwhile jotting them down separately, because they might affect the whole EPUB-WEB discussion:


I would be pleased if somebody on the group, who has a better understanding of these, could comment/update the file!


Ivan Herman, W3C
Digital Publishing Activity Lead
Home: http://www.w3.org/People/Ivan/
mobile: +31-641044153<tel:%2B31-641044153>
ORCID ID: http://orcid.org/0000-0003-0782-2704

- Nick Ruffilo


Received on Tuesday, 12 May 2015 15:55:19 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:36:00 UTC