Access shop variables and use Liquid inside javascript files

Access shop variables and use Liquid inside javascript files

Shopify Partner
19 0 4

Hey Shopify Community 😏


I'm trying to access shop variables like shop.url & inside of an external Javascript file.


I successfully made a script which I've placed between script tags inside of a section file, but I'm trying to clean up my code and reduce the amount of <script> tags I have, so I'm wondering if there's a way to include the .js.liquid file inside of my theme.liquid head, while still maintaining functionality of the liquid?


Usage: I'm creating logging for my themes to get better insight on who uses my themes, mainly to prevent piracy... but that's not the point of this post.


If you have any tips/solutions, don't hesitate to help!



- grim 😀

Reply 1 (1)

Shopify Staff
2873 312 821

Hi Grim,


Unfortunately global variables like the store url or theme name are not accessible in js.liquid files - you can only use the `settings` object and Liquid filters in these js.liquid files. See our docs on this here.


I'll log this as a feature request though!

Liam | Developer Advocate @ 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 or the Shopify Web Design and Development Blog