- From: Jake Archibald <notifications@github.com>
- Date: Wed, 07 Dec 2016 03:44:48 -0800
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
Received on Wednesday, 7 December 2016 11:45:57 UTC
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