So I’m wondering if shopify supports any way of loading a javascript file in on a store site on the same domain as the store and not on the CDN.
This would allow for the use of webworkers and creating Progressive web apps using shopify’s theme’s instead of forcing to create a separate app and using the headless api’s.
Putting a (custom) script in assets and refering it to with the asset_url filter will neatly make a cdn url for it. Which is of course usually what you want.
However https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API Web workers force to load a script file from the same origin as the dom document. If the script is hosted by a cdn, aka not the same origin, then unfortunately it wont work. Which is why I’m trying to find a way to host this js file on the shop store domain.
Web workers are created using new Worker([url to some file]) and that url needs to adhere to same origin policy. It doesnt matter if I call it in a script loaded into the document or in a script tag in the document, the file I’m trying to get needs to be on the same origin as the store, which you indicate is not possible. And that might be true since I’ve found no documentation on how to host assets anywhere else but on the shopify cdn.
I really need a solution and keep getting blocked to work with the api as its limited to 250 calls for each fetch and having this loop through my products crashes my UI so I will need to create a new thread to run this fetch loop, I can do that with worker.