FROM CACHE - en_header

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

Solved
timed
Shopify Partner
29 0 4

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:

 

 

 

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

 

 

 


Example 2:

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

 

 

 

<script>
if(product_data.tags.includes('whatever') {
vm.checkProduct = true
}
</script>

 

 

 



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

 

Accepted Solution (1)

Accepted Solutions
MichalKopec
Excursionist
20 4 4

This is an accepted solution.

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? Contact me with details at shopify@quizzer.dev
Connect with me on LinkedIn: https://www.linkedin.com/in/michalpkopec/
Buy me a coffee: https://www.buymeacoffee.com/MichalKopec

View solution in original post

Reply 1 (1)
MichalKopec
Excursionist
20 4 4

This is an accepted solution.

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? Contact me with details at shopify@quizzer.dev
Connect with me on LinkedIn: https://www.linkedin.com/in/michalpkopec/
Buy me a coffee: https://www.buymeacoffee.com/MichalKopec