Skip to content

Instantly share code, notes, and snippets.

@gauntface
Created July 18, 2017 23:47
Show Gist options
  • Save gauntface/86d9ad679457e9a45460a2b37191b811 to your computer and use it in GitHub Desktop.
Save gauntface/86d9ad679457e9a45460a2b37191b811 to your computer and use it in GitHub Desktop.
Example loading in "workbox.js"
class Workbox {
loadModule(moduleName) {
// Load workbox module from CDN
importScripts(`https://some-cdn.cdn.com/${moduleName}/build/umd.js`);
}
get precaching() {
if (google.workbox.precaching) {
return google.workbox.precaching.default;
}
this.loadModule('workbox-precaching');
return google.workbox.precaching.default;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment