DEV Community

Cover image for Web workers, Service Worker and PWA
Saurabh Kumar Singh
Saurabh Kumar Singh

Posted on

Web workers, Service Worker and PWA

What is web Worker?

Javascript is a single-threaded processing model. Web Workers makes it possible to run a script operation in a background thread separate from the main execution thread of a web application. The advantage of this is that laborious processing can be performed in a separate thread, allowing the main (usually the UI) thread to run without being blocked/slowed down.

A web worker is a tool for multithreading in natively single-threaded Javascript programs. Web workers run in the background and communicate with the main thread via messages.

Web Worker Applications:

  1. Real time text formatting, spell checking, and syntax highlighting
  2. Filtering images in a canvas
  3. Processing large JSON datasets
  4. Processing multimedia (audio and video)

What is Service Worker?

Basically service workers are event-driven workers. They are JavaScript assets that act as proxies between web browsers and web servers. It is helpful in time of creating offline experience and network interrupt by caching certain assets of your application.

There is 3 important part in service worker:
Download : This includes registering worker. It will install service worker in background. Using this will cache most of the assets. You check it in Application section of Dev tool.

Installing & Activation : If it is the first time that assets has been cached then it will be installed and activated after that.
And if there is another version of service worker available then it will be installed but not activated. Activation happens soon after the use of old service worker has completed.

PWA (Progressive Web App)

It is a new software development methodology. Progressive web app are hybrid of native apps and web apps. It includes both capability of native apps and reachability of web apps. PWA promises mobile like features in web apps.

Application of PWA

  1. Offline usability
  2. Page loading speed
  3. Platform independence
  4. Better SEO
  5. No need of platform specific native app development

Web Worker
Service worker
PWA
PWA

Top comments (0)