I can't use javascript file which i added by the shopify theme->assets add

Highlighted
New Member
10 0 0

I tried to use 
{{ 'p_needed.js' | global_asset_url | script_tag }}
{{ 'p_needed.js' | shopify_asset_url | script_tag }}


All of them return 404 error.

This 'p_needed.js' file is in my assets list.

0 Likes
Shopify Partner
294 47 54

You are using the wrong filter for url, if you added the files into assets you should use asset_url filter to load them, so your code should be like this.

{{ 'p_needed.js' | asset_url | script_tag }}
An individual web developer focused on Shopify development.
Need more help? Feel free to drop a direct email shopify@sarhov.com

Author: Hovhannes Sargsyan (aka sarhov).
Website: https://sarhov.com
Email: shopify@sarhov.com
Skype: @sarhov
Messenger: @sarhov
Telegram: @sarhov
1 Like
Shopify Partner
294 47 54

You are using the wrong filter for url, if you added the files into assets you should use asset_url filter to load them, so your code should be like this.

{{ 'p_needed.js' | asset_url | script_tag }}


You can learn more about url filters here . https://help.shopify.com/en/themes/liquid/filters/url-filters

An individual web developer focused on Shopify development.
Need more help? Feel free to drop a direct email shopify@sarhov.com

Author: Hovhannes Sargsyan (aka sarhov).
Website: https://sarhov.com
Email: shopify@sarhov.com
Skype: @sarhov
Messenger: @sarhov
Telegram: @sarhov
0 Likes