Shopify Theme Performance: Understanding Liquid, Sections, Assets and Rendering Bottlenecks

Which Liquid patterns are expensive and what to write instead, with the rendering cost of each shown in the Theme Inspector.

In short

Liquid runs on Shopify's servers, before a single byte reaches the browser. So an expensive template does not make the browser slow — it makes the server response slow, which caps how fast the page can possibly be and cannot be fixed by anything you buy.

This is the part of Shopify performance that merchants cannot do and agencies often skip. Four patterns account for most of it:

  1. Loops over large collections without a limit.
  2. Rendering a snippet inside a loop.
  3. Resolving the same property repeatedly instead of assigning it once.
  4. Filtering or sorting large arrays in Liquid.

The second half of this guide is the browser side: how theme assets load, and how many sections a page carries.

How Liquid rendering costs you time

When a request arrives, Shopify renders your template. Every tag, every loop iteration, every property lookup and every snippet render is work done before the response starts. Add it up and it is your time to first byte.

The browser cannot begin anything until that finishes — not downloading your CSS, not discovering your hero image, nothing. A 900 ms render is 900 ms added to every metric that follows.

Two things make this easy to get wrong. It is invisible in the browser: DevTools shows a slow server and gives no hint why. And it scales with your catalogue, so a template that was fine with 50 products becomes a problem at 5,000.

Profiling it properly

The Theme Inspector

The Shopify Theme Inspector for Chrome extension adds a Liquid profile to DevTools. It shows a flame graph of your template render, with the time spent in each section, snippet and tag.

  1. Install the extension and sign in to your store.
  2. Open the page you want to profile — a collection page with many products is the usual culprit.
  3. DevTools → Shopify tab → profile the Liquid render.

What you should see: a breakdown by file and line. Look for a single snippet or loop accounting for a disproportionate share. That is your target.

Profile a page with realistic data. A collection with 12 products will not reveal a problem that only appears at 500.

Theme Check

shopify theme check runs static analysis against your theme and flags several performance patterns, including expensive loops and deprecated tags. It is not a substitute for profiling, but it catches the obvious things before they ship.

The four expensive patterns

1. Loops without a limit

{%- comment -%} Renders every product in the collection, however many there are {%- endcomment -%}
{%- for product in collection.products -%}
  {{ product.title }}
{%- endfor -%}

{%- comment -%} Only what the page actually shows {%- endcomment -%}
{%- for product in collection.products limit: 24 -%}
  {{ product.title }}
{%- endfor -%}

Use paginate for anything that lists products, and set the page size to what you actually display. A grid showing 24 products should not iterate 500.

{%- paginate collection.products by 24 -%}
  {%- for product in collection.products -%}
    {%- render 'product-card', product: product -%}
  {%- endfor -%}
  {{- paginate | default_pagination -}}
{%- endpaginate -%}

2. Rendering a snippet inside a loop

{% render %} is not free. Rendering a snippet 500 times costs 500 times the snippet's overhead, plus whatever is inside it.

This does not mean never render inside a loop — product cards are a legitimate use. It means reduce the iterations first, and keep what is inside the snippet cheap. A metafield lookup inside a card snippet that runs 500 times is 500 metafield lookups.

Also: use {% render %} rather than the deprecated {% include %}. render isolates scope, which is both safer and faster, because Liquid does not have to carry the parent scope into the snippet.

3. Resolving the same thing repeatedly

Every property access does work. Doing it in a loop multiplies that work.

{%- comment -%} Resolves the metafield on every iteration {%- endcomment -%}
{%- for variant in product.variants -%}
  {%- if product.metafields.custom.badge.value != blank -%}
    <span>{{ product.metafields.custom.badge.value }}</span>
  {%- endif -%}
{%- endfor -%}

{%- comment -%} Resolved once, used many times {%- endcomment -%}
{%- assign badge = product.metafields.custom.badge.value -%}
{%- for variant in product.variants -%}
  {%- if badge != blank -%}
    <span>{{ badge }}</span>
  {%- endif -%}
{%- endfor -%}

The same applies to collection.products.size, settings.something used repeatedly, and any chained lookup. Assign once outside the loop.

4. Filtering and sorting large arrays in Liquid

{%- comment -%} Walks the whole collection in Liquid to find a handful of items {%- endcomment -%}
{%- assign sale = collection.products | where: 'available', true | sort: 'price' -%}

Liquid is not a query language, and doing this work per request is expensive. Where you can, let the platform do the filtering — use a collection that already contains the right products, use storefront filtering, or use sort_by on the collection URL rather than sorting in the template.

A note on product lookups by handle

Looking products up individually by handle (all_products['some-handle']) is limited per page, and each lookup is a separate piece of work. If you are building a curated row, a collection is both cheaper and easier to manage than a list of handles in a setting.

The browser side: how theme assets load

Stop scripts blocking the render

{%- comment -%} script_tag produces a blocking script {%- endcomment -%}
{{ 'theme.js' | asset_url | script_tag }}

{%- comment -%} What you want instead {%- endcomment -%}
<script src="{{ 'theme.js' | asset_url }}" defer></script>

A script without defer or async stops the browser parsing your HTML. On a theme that loads several, this is usually the reason a page is blank while its content has already arrived.

Load per template, not globally

A theme typically ships code for every feature it offers. A policy page does not need the product gallery, the variant picker or the cart drawer.

{%- if template.name == 'product' -%}
  <script src="{{ 'product-gallery.js' | asset_url }}" defer></script>
{%- endif -%}

Section-level {% javascript %} and {% stylesheet %} blocks are combined by Shopify into theme-wide assets, which is convenient but means the code ships on every page that loads those assets. For anything substantial and template-specific, a separate conditionally loaded file is better.

Resource hints

{%- comment -%} Preload the font that renders your headings {%- endcomment -%}
{{ 'brand.woff2' | asset_url | preload_tag: as: 'font', type: 'font/woff2', crossorigin: 'anonymous' }}

{%- comment -%} Connect early to an origin you know you will need {%- endcomment -%}
<link rel="preconnect" href="https://cdn.shopify.com" crossorigin>

Preload sparingly. Two or three at most — they compete for bandwidth, and preloading everything makes the important thing slower.

Keep content_for_header where it belongs

It must stay in the <head>, and it carries Shopify's own required scripts. Do not move it, defer it, or try to remove parts of it.

Section count and DOM size

Every section is markup, usually an image, sometimes a script. Sections above the fold delay your LCP directly; sections below it inflate the DOM, which makes every style recalculation and layout pass more expensive — disproportionately so on a mid-range phone.

Two checks: count the sections above the fold (three is usually plenty), and run document.querySelectorAll('*').length in the console. Several thousand elements on a collection page is worth addressing, usually by reducing what each product card renders.

content-visibility: auto on sections far below the fold lets the browser skip rendering work until they are needed, which is a cheap win on long pages.

Common mistakes

Optimising the browser side while the server response is the problem. Profile Liquid first if TTFB is slow.

Profiling a collection with 12 products and concluding the template is fine.

Removing {% render %} calls without reducing iterations, which changes the cost very little and makes the theme harder to maintain.

Using {% include %}. Deprecated, and slower than render.

Deferring a script the page needs immediately, so the variant picker no longer works on first interaction.

Minifying theme assets and expecting responsiveness to improve. Minification reduces download size, not execution time.

Working on the live theme. Duplicate, change, compare, publish.

Assuming a faster theme is the answer. If your cost is apps and media, a new theme will reproduce your numbers.

Verification

  1. Re-profile the Liquid render on the same page with the same data, and confirm the render time dropped. This is the only direct proof you changed the server side.
  2. Compare TTFB in the Network panel, cold, median of five runs.
  3. Record a page load and confirm render-blocking assets are gone from the critical path.
  4. Check DOM size before and after if that was your target.
  5. Check all three Core Web Vitals. Deferring and preloading both have side effects.
  6. Click through every feature on the templates you touched — gallery, variant picker, filters, cart drawer, search.
  7. Complete a real test order.
  8. Then watch field data for four weeks in Shopify's Web Performance dashboard.

When it still does not improve

  • Liquid render time will not drop → profile again and follow the flame graph rather than guessing. The cost is in a specific file and line.
  • TTFB is slow but the Liquid profile is fast → the cost may be an app's server-side extension, or a section rendering API call. Check what else runs during the request.
  • The render is fast and the page still feels slow → your problem is the browser side: apps, scripts or media, not the theme's Liquid.
  • It is fast with your test data and slow in production → catalogue size. Profile against a realistic collection.
  • A feature broke after deferring → the script was needed before the visitor could interact. Load it earlier, or load it on first interaction rather than deferring it indefinitely.

Keeping a theme fast

Theme performance decays through ordinary work: a new section, a new metafield shown on the product card, a feature added to a snippet that runs 500 times.

What keeps it honest: profile the Liquid on your heaviest template before every theme release, run shopify theme check in your workflow, keep a note of the render time so a regression is visible, and treat anything added inside a loop as a change that needs measuring.

Frequently asked questions

Does Liquid affect Shopify page speed?

Yes, and in a way that is invisible in the browser. Liquid renders on Shopify’s servers before anything is sent, so an expensive template shows up as a slow server response. Nothing in the browser can start until it finishes, and you cannot fix it by buying anything.

Which Liquid patterns are slowest?

Four account for most of it: loops over large collections without a limit, rendering a snippet many times inside a loop, resolving the same property repeatedly instead of assigning it once, and filtering or sorting large arrays in Liquid instead of letting the platform do it.

How do I profile Liquid render time?

Install the Shopify Theme Inspector for Chrome. It adds a Liquid profile to DevTools showing a flame graph of the render, broken down by section, snippet and line. Profile a page with realistic data — a collection with 12 products will not reveal a problem that appears at 500.

Is {% render %} faster than {% include %}?

Yes. {% include %} is deprecated and shares the parent scope, which Liquid has to carry into the snippet. {% render %} isolates scope, which is both safer and faster. Use render everywhere.

Should I use script_tag in my Shopify theme?

Generally no. The script_tag filter produces a blocking script, which stops the browser rendering your page. Write the tag yourself with defer instead, and load template-specific code only on the templates that need it.

How many sections should a Shopify page have?

Above the fold, three is usually plenty — each one delays your LCP. Below the fold the concern is DOM size, which makes every layout and style recalculation more expensive, disproportionately so on mid-range phones. content-visibility on far-below-fold sections is a cheap win.

References