i have checked my website performance in https://gtmetrix.com/.And it says that i need to defer my javascript files. My theme.liquid file is like this:
As you can see i have two js files at head section, when i am trying to put that files at the bottom after tag my product page functionality not working, i have used jquery in script tag in my product page, in that scipt tag i am using also some liquid code. So what can i do , why product page functionality not working when i am puting jquery and slick-carousel at the bottom of my page (also i have tried to put defer keyword in jquery and slick-carousel script tags) sorry for my english. Thanks
2
Answers
<head>
to the bottom of the page, before theapp.js
.</body>
tag.According to the second Vladimir’s suggestion, I propose to wrap inline script from the product page in the condition:
{% if template contains ‘product’ %}
… inline script from product page
{% endif %}
This allow you to add inline script only on the product page.