PWA: what happens if my web app has a service worker without a manifest file?

Viewed 2388

In progressive web application (PWA), it is said to make a web app fully PWA-compliant, I need to have a manifest file.

(1) But what happens if my web app registers a service worker but I didn't define a manifest file? Any typical examples?

(2) Is it correct that service worker is a technique used in PWA, but is not necessarily exclusive to PWAs (i.e. non-PWA web apps could have service workers as well)?

2 Answers

PWAs are Progressive Web Apps which means you progressively enhance your site with the features you need.

  • If you want your site to be installable you'll need a web manifest.
  • If you want your site to cache resources on the device or work offline you'll need a service worker.

Those pieces work independently but complementary and you can pick and choose them at your whim.

Answering to the first part:

  • It won't prompt user for add to home screen as this is one of the requirements for PWA, but PWA isn't limited to it. So if you have Service worker registered, you will get all the other functionalities of PWA other than Add to home Screen.

In precise, loading a manifest files tell browser that our website is an application Answer to your other questions. Can't see any other use of the Service Worker other than PWA, as Service Worker is a proxy, sits between the user and N/W request and decides very cleverly if the internet is available or not or whether the SW should intercept the n/w request or not. So, soon you register SW it automatically counts towards PWA.

Major components of PWA are:

  1. Adding a Web App Manifest
  2. Adding a Service Worker (SW)
  3. Caching and serving Static assets
  4. Serving Cached Contents
  5. Dynamic Caching

Out of these 5 steps, you can achieve 2,3,4,5 with the help of SW. Adding a web app manifest is more like an intimation and giving your website a more native look/feel regardless of desktop or mobile device. cheers :)

Related