lavas-project / hexo-pwa

Hexo PWA plugin
MIT License
133 stars 17 forks source link

Update generate sw-toolbox.js separately to optimize performance #7

Closed nekolr closed 5 years ago

nekolr commented 5 years ago

I don't know why, it is slower to pack the contents of sw-toolbox together into sw.js, but faster to load them separately.

nekolr commented 5 years ago

Final, i found that the performance of the two methods is same, although importScripts does not block the main thread, but as you said, it does send a new request, so i close this pull request.

PengXing commented 5 years ago

Yes, importScripts does not block the main thread, but blocks execution of service worker.

BTW: thanks for your PR.

See this documentation, https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers#Importing_scripts_and_libraries