Understanding the Visual Similarity Score
Ensuring your website renders correctly with critical CSS is crucial for a fast and optimized user experience. PerfBee's Critical CSS feature includes a Visual Similarity score to help you check that your extracted critical CSS accurately represents your above-the-fold content. This article explains how the score works and how to interpret the results.
What the Visual Similarity Score Measures
The Visual Similarity score is a percentage that compares two screenshots of the first screen of your webpage: one rendered with all of its CSS and another rendered with only the critical CSS. It measures how closely the two images match. A higher score indicates a more accurate representation of your page's design with the critical CSS applied. The score is calculated using a combination of methods.
How the Score Works
PerfBee calculates the Visual Similarity score as follows:
- Screenshot Comparison: We capture screenshots of your webpage rendered with its full CSS and with only the extracted critical CSS (the page's own stylesheets are blocked).
- PSNR (Peak Signal-to-Noise Ratio): This metric measures the quality of a reconstructed image compared to the original image. PerfBee turns it into a percentage, where 50 dB or more counts as 100%.
- Pixel-based Comparison: We also compare the two screenshots pixel by pixel and count the share of identical pixels.
- Combined Score: The final score is an average of the PSNR and pixel-based comparison results, resulting in a percentage score between 0 and 100%.
To run the test, click Preview first load under the Mobile, Desktop or Combined CSS in your extraction results. It takes about 20 to 60 seconds and uses no credits. The Page Load Preview window shows both screenshots and a verdict; the exact score is under Technical details as "Visual match". The mobile test uses a 375 pixel wide screen, and the desktop and combined tests use 1920x1080.
The goal is to ensure the page looks as close as possible to the full-CSS version, even with only critical CSS applied initially.
Interpreting the Score
At 70% or above, PerfBee shows "Looks good — ready to deploy": the critical CSS covers the styles needed for above-the-fold rendering. From 45% to 70%, it shows "Acceptable — minor differences on first load"; look at the screenshots to decide. Below 45%, it shows "Normal for content-rich pages": critical CSS only covers the top of the page, so check the "Initial load" screenshot, and if it looks acceptable, the CSS is working.
Troubleshooting a Low Score
If your score is low and the "Initial load" screenshot is missing important styles, the extracted critical CSS might be missing some crucial rules. Here's how to improve it:
- Check Your Critical CSS Settings: Navigate to Critical CSS in the PerfBee dashboard and review your extraction settings.
- Adjust the Settings: Open Advanced Settings and make sure Ignore @import and Ignore @font-face are off, so those rules stay in the critical CSS.
- Re-Extract Critical CSS: After adjusting your settings, re-extract the critical CSS for your page.
- Monitor the Score: Run Preview first load again to see if the score has improved.
Why Not Always 100%?
The Visual Similarity score will rarely reach 100%. Differences in fonts, animations, and dynamic content can cause slight variations between the two renderings. The score is designed to give you a reliable indicator of whether your critical CSS is effectively applied, not to guarantee pixel-perfect matching. A score of 70% or more already counts as good.
By understanding and using the Visual Similarity score, you can make sure your website's critical CSS is correctly implemented, leading to improved page speed and a better user experience. For more detailed information on critical CSS and other features, visit our documentation.