1👍
The same considerations that make scope and location very important when you have a service worker with a fetch
handler do not apply to push
-only service workers.
If you just use the default scope
and register a service worker script that exists somewhere in your origin (navigator.serviceWorker.register('/static/account/sw.js')
in your example), that should be fine for push
events.
I believe that OneSignal and Firebase Cloud Messaging for the web both have client libraries that will register a push
-only service worker for you (configured to use their messaging backend) with a synthetic scope, which is presumably guaranteed not to interfere with any of your actual URLs and accidentally take control of clients that you don’t expect. That’s overkill for what you’re trying to do, though.