Is there a way to pass the handle to a script tag ?

lucas-p
Excursionist
13 0 4

Hey, our app is using the script tag API to inject our script and then fetch some data related to the product page from our API.

But it's pretty slow and I'd like to know if there's a way to know the product handle from the request loading the script tag ?

Thanks by advance

Replies 2 (2)
SBD_
Shopify Staff
Shopify Staff
1098 146 219

Hey @lucas-p 

It's best to parse window.location.pathname in these cases.

Scott | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

lucas-p
Excursionist
13 0 4

Thanks, this is what we're already doing 🙂

I wanted to see if there was no other way to directly pass the handle to the script tag so we can load data at the start and not wait for an extra API call.

But it seems a bit tricky if we're obliged to modify the liquid files.