Re: [manifest] Integration with service workers (#161)

Maybe @jakearchibald can help here with an illustrative example... or at least tell me how wrong I am :)

> @marcoscaceres I'd like to propose re-opening this, I didn't realise it had been closed. I think it's fine if some implementations don't get around to implementing this property for a while, nobody supports the scope property yet either.

The problem is not one of support, it's about use case and functionality. 

> I think this is the key point. The service_worker property would not be the only way for a given Service Worker to be registered, it would just be a way of ensuring that it gets registered the moment a user installs an app. Otherwise, the app will only work offline the second time the app is launched.
 
This is the bit I really don't understand - and I need some enlightenment here. As far as I can see, it means throwing away all the registration machinery that a developer gets with `navigator.serviceWorker.register()`. Would they, and us, really want to do that? 

Additionally, there is no guarantee that the SW will be registered/ready in time before the user re-launches the app. The same machinery that governs installation of SW still applies, so installation can fail or be rejected for all the standard reasons. A user could also open the application while the UA is still waiting for the SW script to d/l, etc.... unless the web application is blocked from launching until the SW becomes ready, which might also be kinda sad (as it might never finish installing). 

I don't understand why developers wouldn't just do the following prior to installation (or what advantage the manifest brings over just doing the following prior to installation of the web app):

```JS
//Register the SW when the page first loads. Done. 
if ('serviceWorker' in navigator) {
  window.addEventListener("DOMContentLoaded", (e) => {
    navigator.serviceWorker.register('/app/sw.js', {
      scope: '/app/'
    })
    .then(reg => console.log('Yey!', reg))
    .catch(err => console.log('Boo!', err));
  });
}

``` 

I'm still hoping someone can explain this to me. If possible, a real-life example would be great. 

> I think being able to use a Service Worker as an installation script for an app by hooking into the worker's "install" event could be hugely powerful. Not just for downloading resources of the app into a cache for offline use, but for all kinds of purposes.

Sure, I agree: but that's a general statement that applies to service workers, and the apps that use them, at large. By having this in manifest, what you are implying is that those capabilities only be made available to manifest-supporting user agents (as it would be only those user agents that would install that particular SW). At least, there is a risk that a developer could unwittingly exclusively target manifest supporting UAs  - and I think that's pretty sad.    



---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/manifest/issues/161#issuecomment-70040263

Received on Thursday, 15 January 2015 05:05:36 UTC