As we know service worker is registered from the root of the project folder but, is there any way to fetch some static resources (css, js) from different domain(s)?
Example :
myWebsite.com
// main url (e.g. index.html)abc.com/css/style.css
// css file pathxyz.com/js/jsFile.js
//javascript file path
It is by default possible to fetch and cache cross-origin resources according to the specification:
Any request that comes from the page (except iframe sub-resources) will pass through the service worker. These resources can be from the same or different origin. You can cache these resources so that they are available offline however as a developer you can't manipulate or inspect the contents of them unless the resources have the correct CORS header set.
For example, in your install event, you can Cache a remote file that is not on your domain.