Image Assets in JS

Shopify Partner
253 0 0
Any way to call an image asset from an external JS file in a theme? For example, the equivilent of {{ 'loading.gif' | asset_url }}.
Cliff Spence
Shopify Staff
Shopify Staff
2002 0 41

I recommend exporting a base url from the main theme for the js.

Something like

var asset_url = {{ '' | asset_url };

I’m thinking however of providing a global JS file which exports those variable locations in a unified way.

Tobias Lütke - Shopify CEO //