Is it better performance to check product tags in liquid or javascript?

15 0 3

We have a store that has some vue.js slapped in it and curious to know what is a better way to check against product tags in regards to store performance. 

Example 1:




var checkProduct = false
{% if product.tags contains 'whatever' %}
var checkProduct = true
{% endif %}




Example 2:

Since we store product data on the vue model i can check against them with




if(product_data.tags.includes('whatever') {
vm.checkProduct = true




Is there any benefit in doing either way of the above in regards to performance?

If i put liquid inside of a script tag does it just convert it to it's js equivalent anyway when it renders? And if it does then it would mean that there's no real difference?

Thank you


Reply 1 (1)
9 1 2

The version with liquid tags will put more processing on the server so the response of the can be marginally slower. When there's a lot of requests this can make a difference. Without doing any testing for speed between the two I'd choose the JavaScript option.

Have a problem with your Shopify store? Time is money! Let me fix that for you for a fraction of the opportunity cost. Contact me for details.