Used and critical CSS

Critical CSS, used CSS, safe rollout, health checks, rollback, and selector recovery.

2 min readPart of Performance Optimisation

Critical CSS and used CSS are independent, opt-in pipelines. Critical CSS prepares above-the-fold styles for a template; used CSS builds a page-specific stylesheet from selectors observed in the rendered URL. Start with one pipeline and test builder and dynamic states.

Critical CSS

When criticalCSS is enabled, the plugin generates a bounded, per-template critical stylesheet and serves it through the current template-enhancement/output-buffer path. It keeps a full-stylesheet fallback and respects strict CSP, size, retry, and commerce-exclusion settings. Generation status and failures are visible in the dashboard rather than silently treated as a successful render.

Used CSS

When removeUnusedCSS is enabled, the plugin parses the rendered URL and queued styles, preserves a built-in and user safelist, and writes a page-specific result with freshness checks. Dynamic state classes, builder output, and JavaScript-created markup belong in the safelist. A page purge removes the derived result so the next safe render can rebuild it.

Safe rollout

  1. Enable the feature on staging.
  2. Use Preview/Dry Run and inspect the generated selector list.
  3. Promote only after the health check passes.
  4. Keep the last-good artifact available for rollback.
  5. Re-test after a builder update, theme switch, or major template change.

Settings

KeyDefaultPurpose
criticalCSSfalseGenerate template critical CSS.
removeUnusedCSSfalseBuild per-URL used CSS.
excludeUnusedCSS, ccssSafelistExtra\'\'Keep project-specific selectors.
usedCSSDeliveryModefileChoose the safe file delivery mode.
ccssMaxRetries, ccssGenTimeout5, 25Bound generation retries and timeout.

When styles disappear

Add the dynamic selector to the relevant safelist, regenerate the affected URL, and inspect the health result. If the page still breaks, disable only the failing pipeline and clear its derived cache. A full-site deletion is a last resort, not the first diagnostic.