How Lighthouse Calculates AVIF Byte Savings

Google Lighthouse evaluates page performance by identifying opportunities to reduce payload sizes, including migrating legacy image formats to next-generation formats like AVIF. Instead of performing intensive, real-time image re-encoding during an audit, Lighthouse relies on empirical heuristic models to estimate the compressed size of images converted to AVIF. By subtracting this estimated file size from the original transfer size and filtering the results against specific minimum thresholds, Lighthouse calculates the total potential byte savings reported in its audits.

1. Identifying Eligible Images

Before any calculations occur, Lighthouse analyzes the page’s network activity to identify candidate images during the "Modern Image Formats" audit. The tool inspects network requests and filters for raster formats that benefit from modern compression, primarily JPEG, PNG, and older WebP files. Vector graphics (SVG), icons, and images that are already served as AVIF are excluded from the calculation.

2. Heuristic Size Estimation

Encoding full-resolution images into AVIF during a client-side audit would require excessive CPU resources and significantly slow down the auditing process. To avoid this overhead, Lighthouse uses an empirical estimation algorithm based on image dimensions and visual density rather than performing actual compression:

3. Calculating Potential Byte Savings

Once the estimated AVIF size is calculated, Lighthouse determines the savings for each image:

\[\text{Byte Savings} = \text{Original Transfer Size} - \text{Estimated AVIF Size}\]

If the original image is already compressed heavily enough that an AVIF version would yield negligible or negative savings, the calculation returns zero savings for that file.

4. Applying Minimum Thresholds

To keep audit reports actionable and prevent flagging minor optimizations that have virtually no impact on page load times, Lighthouse applies thresholds:

5. Final Aggregation and Scoring

Lighthouse aggregates all individual byte savings that exceed the threshold to display the total potential data reduction in KiB or MiB. It also estimates the potential load time improvement (in milliseconds) based on the simulated network conditions of the run, giving developers a clear metric of how adopting AVIF will improve page delivery.