GoogleChrome / lighthouse

Automated auditing, performance metrics, and best practices for the web.
https://developer.chrome.com/docs/lighthouse/overview/
Apache License 2.0
28.02k stars 9.32k forks source link

core: split up `CSSUsage` artifact #15952

Closed adamraine closed 2 months ago

adamraine commented 2 months ago

Closes https://github.com/GoogleChrome/lighthouse/issues/15890

The general problem is that CSS usage tracking has a large performance overhead. Prior to https://github.com/GoogleChrome/lighthouse/pull/15865 we were side-stepping the issue by only looking at CSS usage at the end of the navigation. One of the goals if this PR is to revert back to this behavior.

However, it does not make sense to examine CSS usage at a single point in time in timespan mode. So to avoid the performance overhead problem in timespan mode, this PR disables CSS usage tracking in timespan mode. This is achieved by splitting up CSSUsage into two gatherers.

This enables certain audits (e.g. unminified-css) to examine the available stylesheets in timespan mode without needing to run through the expensive rule tracking instrumentation.

User visible changes: