I’m using Shopify Liquid.
If I don’t include {% if my_array %}
and have a code such as this:
{% for var in my_array %}
Do this heavy task
{% endif %}
does it skip the "heavy task" if my_array is empty or is it better to include the if statement (performance wise)?
Thank you.
3
Answers
Thank you for your answers, but I found this from Shopify developers documents. According to Shopify,
{% for var in my_array %}
also acts like an if statement, which can be combined with{% else %}
for when the array is empty. for example:Hope this helps others searching for it too.
Since you’re writing it in liquid, you won’t see any performance issues since the result will already be written when the page loads.
If you only need to check whether it is empty or not