I audited 14 Shopify themes last quarter for speed. 11 of them blamed apps. None had touched Liquid loop count, capture-in-loop allocations, or image output.
After optimizing 100+ Shopify stores over 12 years: the code-level patterns in your theme files account for 40-60% of total render time. Apps matter. Images matter. The template layer is where the compounding problems live.
Here are the 5 Liquid patterns that move the needle.
1. Drop capture from loops
assign stores a value. capture renders a full block and stores it as a string. Using capture inside a loop means a new string allocation on every iteration.
Slow β 48 allocations on a 48-product collection:
{% for product in collection . products %} {% capture product_card %} <div class="product-card"> <h3> {{ product . title }} </h3> <p> {{ product . price | money }} </p> </div> {% endcapture %} {{ product_card }} {% endfor %}
Enter fullscreen mode
Exit fullscreen mode
Fast β direct output, zero allocations:
{% for product in collection .β¦