Re: [w3c/ServiceWorker] When should "imported scripts updated flag" be unset? (#1021)

I quite like the currently specced behaviour, as it means I can do something like this:

```js
addEventListener('install', event => {
  importScripts('heavy-script.js');
});

addEventListener('fetch', event => {
  const url = new URL(event.request.url);

  if (url.pathname == '/whatever/') {
    importScripts('heavy-script.js');
    event.respondWith(heavyThing());
  }
});
```

I can cache some heavy scripts, but avoid the cost of executing them on each service worker startup. I can take that hit only when I need it.

Does it make sense to do this? We should think about this in a world with [`import()`](https://github.com/tc39/proposal-dynamic-import).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/1021#issuecomment-265426953

Received on Wednesday, 7 December 2016 11:45:57 UTC