I manage multiple sites that use third party services for sending push notifications. The services require registering a service worker and they each supply the code for the service worker.
One has
importScripts('https://url-of-their-js-file');
and the other has
self.importScripts('https://url-of-their-js-file');
That’s it for each of them. There’s no scoping or functions or anything.
According to MDN:
The self read-only property of the WorkerGlobalScope interface returns a reference to the WorkerGlobalScope itself
So then why is self
necessary at all? Are these two lines any different or can I just remove self.
from the second one?