How to register a service worker from a different domain How to register a service worker from a different domain google-chrome google-chrome

How to register a service worker from a different domain


This does not seem possible as a SecurityError exception would be included in the rejected Promise if the origin of scriptURL is not client's origin. See the spec on the Registration Algorithm.

Even if possible, there would be few advantages to do so as the service worker's scope, a URL, must have the same origin as the page that registers the service worker.

About the iFrame, there are restrictions in place to prevent you from throwing an https: on an http: page and using that to register a service worker. See DOMException when registering service worker inside an https iframe.