Service Worker | Web Fundamentals

Things to note about a service worker:

  • It is a JavaScript File.
  • They execute on a separate thread from the UI.
  • It can’t access the DOM directly.
  • There is a life cycle or a series of events for a service worker.
  • They are isolated to the origin or domain they are registered with.
  • Service Workers require HTTPS.

Service Workers Work?

Basic Setup of the Service worker

First, make a Basic Html File and add a script in a file (eg: sw.js).

In the script, check if Browser supports ServiceWorker or not?

Then add a script that does all the stuff you want your service worker to do.

If you want to learn or add more features to the code, you can check the above code. (https://github.com/abhayjain13/service-worker)

--

--

--

Developer with 3 yrs of industrial experience in developing scalable web applications.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Sample Problems on Mean,Median,Mode

Why i created twitter clone using next js and what i learned ?

Create Custom Libraries in Angular 6

Bridging Green- and Brownfield Apps With ParcelJS

Writing a docker file for your node js typescript micro-service.

Read static files in Netlify Functions API

Two way SSL encryption using nodejs

How To Create A Quiz App in React

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhay Jain

Abhay Jain

Developer with 3 yrs of industrial experience in developing scalable web applications.

More from Medium

Beginners Guide to React’s Custom Hooks

Create your own Social Links Tree with React from scratch.

Adding Firebase Analytics to React Application — The Simple Way

Collaborative Drawing App: Communicating with Sockets