Search in This Blog

how to load javascript file from assets folder in shopify

How to load JavaScript file from assets folder in Shopify

We all already know that Shopify assets folder's path is random and unique name for each Shopify store holders. If you upload some graphics files or JavaScript files or any other files in your Shopify store's assets folder, then how can you identify it's real pah?

For this situation we can use "asset_url" keyword.

For image:

<img src="{{ 'myjavascript.jpg' | asset_url }}" />

For javascript file:
<script type="text/javascript" src="{{ 'myjs.js' | asset_url }}"> </script>

if you want to load only JavaScript file then you can also use this alternative
{{ 'filename.js' | asset_url | script_tag }}

So now we can say for other files we can modify the above code as per our requirements with keyword "{{ 'filename' | asset_url }}".