Extracting Critical CSS for a Single URL
This guide explains how to extract critical CSS for a single URL using PerfBee. This feature helps you optimize your website's performance by identifying the CSS needed to render the above-the-fold content, which you then inline in your page, improving your Core Web Vitals (especially LCP).
How to Extract Critical CSS
Follow these steps to extract critical CSS for a single URL:
- Open Critical CSS in the sidebar of your PerfBee dashboard. The New Extraction tab opens.
- Enter the URL of the page you want to analyze in the URL List field.
- Check the Viewport Settings. Every extraction runs for a mobile and a desktop viewport. The default sizes are mobile (375×667) and desktop (1920×1080); you can pick a device preset or enter a custom size.
- Click "Extract Critical CSS". PerfBee will then render the page in a headless Chromium browser at each viewport size.
- Review the Results. Once the extraction is complete, you'll see the following:
- Mobile, Desktop and Combined CSS: The critical CSS for each viewport, and both together in one file.
- Size: The size of each file, which helps you understand its impact.
- Visual Similarity Score: Click Preview first load under a file to compare a screenshot of the page styled with only that critical CSS against the fully styled page. The score is a percentage from 0 to 100%. At 70% or higher, PerfBee reports "Looks good — ready to deploy".
- Copy the CSS: Open the CSS view of a file and use the Copy or Download button.
- Implement the CSS: Add the extracted CSS inside a
<style>tag in your website's<head>section to improve rendering performance.
Understanding the Results
PerfBee uses a headless browser to render the page and extract the necessary CSS. The extracted CSS is the CSS required to render the visible content above the fold. The visual similarity test is a separate step: it loads the page again and compares screenshots, which helps you assess the quality of the extraction. A higher score means the critical CSS draws the first screen closer to the final page.
Credit Cost
Extracting critical CSS for a single URL costs 1 credit per URL, for the mobile and desktop CSS together. The similarity test uses no credits. Your current credit balance is always visible in the top-right corner of your PerfBee dashboard. Remember that credits reset on the 1st of each month (UTC).
For more information, visit our documentation.