--- title: Stylesheet content subsetting description: >- Learn how Shopify subsets CSS from stylesheet tags so that storefront pages only load the styles they need, and how to make your theme compatible. source_url: html: >- https://shopify.dev/docs/storefronts/themes/best-practices/performance/stylesheet-subsetting md: >- https://shopify.dev/docs/storefronts/themes/best-practices/performance/stylesheet-subsetting.md --- # Stylesheet content subsetting Shopify automatically subsets CSS from [`{% stylesheet %}`](https://shopify.dev/docs/api/liquid/tags/stylesheet) tags so that each storefront page only loads the styles it needs. Instead of bundling all `{% stylesheet %}` CSS from every theme file into a single payload, Shopify identifies which files are part of the page's render tree — the set of Liquid files (sections, blocks, and snippets) that are actually rendered on that page — and includes only their CSS. This reduces the amount of CSS that browsers download and parse, which improves page load times for merchants and their customers. *** ## How subsetting works When a storefront page is rendered, Shopify determines which Liquid files are part of the page's render tree. Only the CSS from those files' `{% stylesheet %}` tags is included in the linked `styles.css` file. For example, if `sections/collection.liquid` renders `snippets/product-card.liquid` using `{% render 'product-card' %}`, then both files' `{% stylesheet %}` CSS is included on any page that renders the collection section. The snippet's CSS is included because its parent (the collection section) is in the render tree. ### What isn't affected The following types of CSS aren't subject to subsetting: * **Asset stylesheets**: CSS files in the `assets/` folder that are loaded through `{{ 'style.css' | asset_url | stylesheet_tag }}` continue to work as before. They're included based on where you reference them in your layouts and templates. * **Inline styles**: Inline `style` attributes on HTML elements aren't affected. * **HTML ` ``` If you insert the full section response into the DOM, then the styles are included automatically. If you insert only a portion of the response, then you also need to extract the `