Skip to Content
02 June, 2026

Shopify Theme Performance: Liquid Optimisation Techniques That Actually Work

Shopify Theme Performance: Liquid Optimisation Techniques That Actually Work

Table of Content

Shopify Liquid is a templating language designed for safety, not speed. Every Liquid loop runs server-side on Shopify’s infrastructure, and every database lookup inside that loop adds latency to your page’s time to first byte. Most Australian Shopify themes we audit have between three and eight Liquid patterns that double or triple their TTFB. This article walks through the ones we see most often and how to fix them without rebuilding your theme.

The N+1 problem in Liquid

The most common performance debt in Shopify themes is the N+1 query pattern. A theme renders a list of products, then for each product it fetches the variant, the metafields, the inventory level, and the related collection. Each lookup is a separate database call. For a collection page with 24 products, you can easily generate 100 or more queries.

The fix is to pre-fetch what you need outside the loop and reference it inside. Shopify provides bulk access via tags like product.metafields, product.selected_or_first_available_variant, and collection.products. Use them. Avoid fetching the same data multiple times inside nested loops.

Metafields: the silent latency tax

Metafields are the most flexible way to add custom data to Shopify objects, but they are also the most performance-sensitive. Every metafield lookup is a database read. A product card that references three metafields runs three database reads. Render 24 product cards and you have 72 reads.

Three optimisation patterns: pin metafields to the storefront via the Admin API so they are eagerly loaded, group related fields into a single metaobject so you fetch them in one read, and avoid metafields entirely for data that does not change per product (use theme settings instead).

Section caching with the Section Rendering API

The Section Rendering API lets you fetch a single rendered section asynchronously instead of reloading the whole page. This is the foundation of fast cart drawers, filter updates, and quick-view modals on modern Shopify themes.

The performance benefit is twofold: the user perceives instant updates because only one section re-renders, and Shopify can cache the section response separately from the parent page. Use it for any UI that updates frequently without a full navigation.

Fragment caching for expensive partials

If you have a Liquid partial that does heavy work (a complex menu, a personalised banner, a calculated price ladder), wrap its output in fragment caching using the Theme Cache or by storing pre-rendered HTML in a metafield. The first request pays the cost; every subsequent request reads the cached fragment.

This pattern is especially powerful for menus that are identical for every user. There is no reason to recompute the menu Liquid on every page load.

Conditional rendering: do not ship what you do not need

Many Shopify themes render every possible feature on every page, even when most are unused. A theme that supports gift wrap, subscriptions, pre-orders, back-in-stock, and quick-view will load partials for all five on every product page, even if only one is enabled.

Audit your theme’s product template and remove or conditionally guard any feature you do not use. The Liquid that does not run cannot slow your page down.

The capture tag trap

The capture tag in Liquid stores a rendered block in a variable. It is useful for re-using rendered HTML, but it is often misused. Themes that capture large blocks of HTML inside loops can balloon memory usage and slow rendering significantly.

Use capture sparingly. If you find yourself capturing inside a loop, refactor the logic so the capture happens once and the loop reuses the result.

Render vs include

Shopify Liquid offers two ways to include partials: the older include tag and the newer render tag. Use render. It is faster because it does not share the parent scope; Shopify can isolate and cache its output. Include creates more work for Shopify’s parser and is being deprecated.

If your theme still uses include anywhere, replace those tags with render and pass explicit parameters. This single refactor often shaves 50 to 100ms off TTFB on Liquid-heavy templates.

Server-side filter the data, not the template

If you need to display only certain products from a collection (in stock, on sale, tagged a certain way), do the filtering at the Shopify Storefront API level or via Search and Discovery, not inside Liquid. A Liquid for-loop with a where filter still fetches the full dataset and filters in template, which is slow.

Filtering at the data layer reduces the number of objects Liquid has to iterate. For large catalogues, this is the single biggest performance lever on collection pages.

Measuring Liquid performance

Shopify provides server timing headers that show how long each section took to render. Open Chrome DevTools, Network tab, click on the document request, and look at the timing tab. Sections that take more than 100ms each are candidates for optimisation.

For deeper analysis, the theme inspector in the Shopify GraphiQL App can show you which Liquid objects were resolved and how many database queries each generated. This is the closest thing Shopify has to a slow query log.

When the theme is the bottleneck

If you have applied the above patterns and your TTFB is still above 800ms, the theme itself may need a structural refactor. A theme written before 2022 may not use Shopify’s modern data access patterns, and patching it can only take you so far. At that point, a focused rebuild on a modern theme architecture is the better investment than continued tuning.

Our Sydney web development team specialises in Shopify theme refactors with performance budgets baked into the build process. We have written more about when to refactor versus rebuild in when Sydney web development must go beyond templates.

Liquid optimisation is the least glamorous part of Shopify performance work. It is also the part with the largest payoff on TTFB, which feeds into every other metric. Get your Liquid right and the rest of the optimisation work becomes much easier.

Insights

The latest from our knowledge base