How can I connect a JS file to a customized product?

I have been struggling to make this work but on the old theme, I could directly link my js to the product template. Now due to it being .json file I was wondering if I could add it to the render file located in Sections. The code below does not work. What am I missing?

Hi @Vy25 ,

You can follow the instruction below:

  1. Go to Online Store->Theme->Edit code
  2. template->/theme.liquid->Paste the code below before the closing tag

{% if template contains ‘product’ %}

Link js

{% endif %}

If you feel like my answer is helpful, please mark it as a SOLUTION. Let me know if you have any further questions.

1 Like

Thank you for the reply!

I feel really close but for some reason it wont load.

The css I linked worked like a charm but the js for some reason doesn’t run the functions within

Hi @Vy25 ,

You can try remove defer.

Thanks