I’m try to use Service Worker in Shopify to make my store faster. The code like this :
(function (){
navigator.serviceWorker.register("https://cdn.shopify.com/xxx/sw.js")
.then((reg) => {
console.log("reg",reg);
}).catch((err)=>{
console.log("err",err)
});
})()
and i got the error.
err DOMException: Failed to register a ServiceWorker: The origin of the provided scriptURL ('https://cdn.shopify.com') does not match the current origin ('https://www.xxx.com').
How should I write it ? thank you for every answer。 :)