Alternative to ScriptTag to add a .js file to user's storefront

New Member
13 0 0

Hi all,

Currently I am developing an app that adds a floating image to a Shopify storefront. This is done by ScriptTag using .js hosted under my domain. However, I have to pass a variable to this .js file and that variable is different for every Shopify store. 

 

Is there a better way than passing asdfasf.js?parameter=afadf? Or is there a way to add a .js file to user's store and make sure it applies to all themes?

Any help is much appreciated!

0 Likes
Highlighted
Shopify Staff
Shopify Staff
591 0 44

You could generate custom script tags for each shop and render them with the appropriate values within them. You can add a cache policy to the response so clients don't need to fetch the JS file on subsequent page loads.

0 Likes
New Member
13 0 0

Could you please provide a small example? How can I go about using custom script tags?

0 Likes
New Member
8 0 0

Hi Chris,

I'd definitely be interested if you had such an example, too.

0 Likes