Skip to main content
Performance

Shopify CSS Subsetting for Stylesheet Tags: What Theme Developers Must Fix

Shopify now subsets CSS from Liquid stylesheet tags by each page's render tree. Learn which co-located patterns are safe, why unrelated cross-file classes can disappear, and how Theme Check finds them.

5 min read
ShopifyCSSPerformanceTheme Check

Starting April 20, 2026, Shopify automatically delivers only the {% stylesheet %} CSS associated with Liquid files in the current page's render tree. This reduces how much CSS a browser downloads and parses, but it exposes a fragile pattern in some themes: a class defined in one component's stylesheet tag and used by an unrelated component.

If your styles are already co-located with the section, block, or snippet they belong to, the update should require no code changes. If styles depend on an unrelated file merely happening to render on the same page, they can disappear.

How Shopify decides which CSS to include

Shopify builds a render tree from the sections, blocks, and snippets actually rendered on a page. It then includes CSS from the {% stylesheet %} tags inside those files in the generated styles.css payload.

Imagine sections/featured-collection.liquid renders snippets/product-card.liquid:

<div class="featured-collection__grid">
  {% for product in section.settings.collection.products %}
    {% render 'product-card', product: product %}
  {% endfor %}
</div>

{% stylesheet %}
  .featured-collection__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.5rem;
  }
{% endstylesheet %}

The section is in the render tree, and the product-card snippet is its direct rendered child. CSS kept in either participating file is eligible for that page.

The safe pattern: component ownership

A Liquid file can safely style:

  • markup in that same file;
  • markup in a snippet it directly renders;
  • markup owned by a direct descendant in the render tree.

The easiest rule is even stricter: define a component's classes beside the component markup whenever practical.

<article class="product-card">
  <h3 class="product-card__title">{{ product.title }}</h3>
</article>

{% stylesheet %}
  .product-card {
    display: grid;
    gap: 0.75rem;
  }

  .product-card__title {
    margin: 0;
    font: inherit;
  }
{% endstylesheet %}

This snippet cannot render without bringing its own stylesheet-tag CSS into the page's render tree. The relationship is visible to both a developer and Shopify.

The unsafe pattern: accidental cross-file dependency

Suppose sections/header.liquid defines a generic .site-banner class in its {% stylesheet %} block. Later, sections/footer.liquid reuses that class but does not render the header and is not its child.

That footer now relies on the header being somewhere else in the page. On a template or render request without the header, Shopify has no reason to include the header's stylesheet-tag CSS, so the footer's banner can become unstyled.

The class name is not the problem. The invisible ownership relationship is.

Fix it in one of three ways:

  1. Move the rule into the Liquid file that owns the markup.
  2. Move genuinely shared styles into a common ancestor that directly renders every consumer.
  3. Put truly global utilities or tokens in an asset stylesheet that the layout intentionally loads.

Do not duplicate a large block of CSS across many files as a first response. Decide whether the style is component-scoped or genuinely global, then give it one understandable owner.

CSS that is not subset

The 2026 change specifically concerns CSS inside Liquid {% stylesheet %} tags. Shopify's documentation says these mechanisms continue under their existing loading behavior:

  • CSS files in /assets loaded with asset_url and stylesheet_tag;
  • inline style attributes;
  • ordinary HTML <style> tags;
  • CSS inside Liquid {% style %} tags.

That does not make <style> or inline declarations a general workaround. Use each mechanism for its intended role. Liquid {% style %} is useful when the declaration itself needs Liquid values; an asset stylesheet is appropriate for a deliberate global system; {% stylesheet %} is strong for static component-owned CSS.

Find problems with Theme Check

Shopify's ValidScopedCSSClass check detects class usage that depends on a stylesheet tag from an unrelated Liquid file. It is enabled in the recommended Theme Check configuration.

Run:

shopify theme check

Treat each warning as an architecture clue. Search for all definitions and consumers of the class, identify the render relationship, and move the rule only after you understand whether it is local or global.

A text search can find static class names, but dynamic classes need manual attention:

<div class="card card--{{ section.settings.style }}">

Audit the generated variants and every template that can output them. Theme Check is a strong first pass, not a substitute for visual coverage.

Remember the Section Rendering API

Subsetting follows the Liquid render tree for both full pages and section-rendering responses. If JavaScript requests a section independently, that response must not depend on an unrelated section's stylesheet tag.

Test drawers, quick views, predictive search, filters, and cart updates that fetch HTML outside the initial page request. A component that looks correct after a full page load may fail when inserted from a partial render if its styles were supplied accidentally by another component.

A practical audit sequence

  1. Update Shopify CLI and Theme Check.
  2. Run shopify theme check and group ValidScopedCSSClass findings by component.
  3. Review every {% stylesheet %} tag for selectors that appear outside its file and direct children.
  4. Move component rules to their owner and global rules to an intentional asset.
  5. Test every main template with hard reloads and an empty browser cache.
  6. Test Section Rendering API interactions separately.
  7. Compare CSS payload size and visual-regression results before and after the refactor.

Do not test only the homepage. Product, collection, article, search, cart, account, password, and 404 templates can have distinct render trees.

Shopify's stylesheet subsetting guide includes compatible and incompatible patterns, and the April 2026 changelog entry records the rollout date and action required.

For broader theme quality checks, use common Shopify development mistakes and the HTML-to-Liquid manual review checklist. A fast stylesheet is valuable only when the rendered component remains correct and accessible.

Found this helpful?

Share it with your network!

Ready to Convert HTML to Liquid?

Try our free HTML to Liquid converter and build your Shopify themes faster.

Try HTML2Liquid Now