Async importScripts() in SW is problematic
jeffposnick opened this issue · comments
As per the SW spec, and summarized at w3c/ServiceWorker#1319 (comment), calls to importScripts()
are allowed either during the initial, synchronous, top-level SW execution or during the install
event handler.
Chrome doesn't currently follow the spec and allows arbitrary, async importScripts()
, but this is a bug that needs to be fixed.
Using this library could lead to folks to inadvertently calls importScripts()
in a way that is meant to be disallowed, and (if they only test on Chrome) erroneously thinking that everything works fine because Chrome isn't throwing an exception.
Hm...
Good that you file this. I’ll leave it like this for now as the only alternative would be fetch()
+ eval()
, which is not CSP compliant. I’ll add a note to the README.
On second thought, I’ll leave this open and think a bit more on what the right course of action is