[w3c/ServiceWorker] get importScripts to work offline (#1555)

Hi guys, does anyone know how to import scripts in the service worker while being offline?

I tried caching the resource I want to import, but is not working :/ 
```
async function getIdb() {
  if (typeof idb === 'undefined') {
     try {
       self.importScripts('https://cdn.jsdelivr.net/npm/idb@5.0.7/build/iife/with-async-ittr-min.js')
     } catch (err) {
       console.log('err idb')
    const cache = await caches.open(STATIC_CACHE_NAME)
    const cacheIdb = await cache.match(
      'https://cdn.jsdelivr.net/npm/idb@5.0.7/build/iife/with-async-ittr-min.js'
    )
    self.importScripts(cacheIdb)
    }
  }
}

getIdb()
```
Any ideas?

-- 
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/1555

Received on Sunday, 29 November 2020 19:55:04 UTC