Talk describing the difference and similarities between web workers and service workers and their use cases in the browser. Mumbai Javascript meet up 2018
16. What is a web worker?
A worker is an object created using a constructor that
runs a named JavaScript file in the background.
17. What is a web worker?
A worker is an object created using a constructor that
runs a named JavaScript file in the background.
Browser spawns a new dedicated worker thread for the
web worker
18. What is a web worker?
A worker is an object created using a constructor that
runs a named JavaScript file in the background.
Browser spawns a new dedicated worker thread for the
web worker
Has its own global execution context, i.e
self !== window
19. What is a web worker?
A worker is an object created using a constructor that
runs a named JavaScript file in the background.
Browser spawns a new dedicated worker thread for the
web worker
Has its own global execution context, i.e
self !== window
Communicate to the main thread via the postMessage
API
30. What can web workers do?
Regular javascript operations
31. What can web workers do?
Regular javascript operations
JSON parsing / stringify
32. What can web workers do?
Regular javascript operations
JSON parsing / stringify
indexDB
33. What can web workers do?
Regular javascript operations
JSON parsing / stringify
indexDB
fetch / Ajax
34. What can web workers do?
Regular javascript operations
JSON parsing / stringify
indexDB
fetch / Ajax
Virtual DOM
35. What can web workers do?
Regular javascript operations
JSON parsing / stringify
indexDB
fetch / Ajax
Virtual DOM
FileReader, Blob, ArrayBuffer
36. What can web workers do?
Regular javascript operations
JSON parsing / stringify
indexDB
fetch / Ajax
Virtual DOM
FileReader, Blob, ArrayBuffer
btoa(), atob()
37. What can web workers do?
Regular javascript operations
JSON parsing / stringify
indexDB
fetch / Ajax
Virtual DOM
NO ACCESS TO MAIN DOM
FileReader, Blob, ArrayBuffer
btoa(), atob()
45. Service worker is a programmable network proxy,
allowing you to control how network requests from your
page are handled.
What is a service worker?
46. Service worker is a programmable network proxy,
allowing you to control how network requests from your
page are handled.
What is a service worker?
Has is own global execution context, i.e self !== window
47. Service worker is a programmable network proxy,
allowing you to control how network requests from your
page are handled.
What is a service worker?
Has is own global execution context, i.e self !== window
Runs in the background