Skip to content

Commit

Permalink
core: update to windowed cumulative-layout-shift
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed May 24, 2021
1 parent 7cec265 commit b38fd27
Show file tree
Hide file tree
Showing 18 changed files with 617 additions and 1,038 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,9 @@ module.exports = [
firstContentfulPaintAllFrames: '<5000',
largestContentfulPaint: '>5000',
largestContentfulPaintAllFrames: '<5000',
cumulativeLayoutShift: '0.001 +/- 0.0005',
cumulativeLayoutShiftAllFrames: '0.197 +/- 0.001',
layoutShiftAvgSessionGap5s: '>0',
layoutShiftMaxSessionGap1s: '>0',
layoutShiftMaxSessionGap1sLimit5s: '>0',
layoutShiftMaxSliding1s: '>0',
layoutShiftMaxSliding300ms: '>0',
layoutShiftMaxSessionGap1sLimit5sAllFrames: '0.197 +/- 0.001',
cumulativeLayoutShift: '0.197 +/- 0.001',
cumulativeLayoutShiftMainFrame: '0.001 +/- 0.0005',
oldCumulativeLayoutShift: '0.001 +/- 0.0005',
},
{
lcpInvalidated: false,
Expand Down
12 changes: 4 additions & 8 deletions lighthouse-core/audits/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ const ComputedTimingSummary = require('../computed/metrics/timing-summary.js');
/** @type {Set<keyof LH.Artifacts.TimingSummary>} */
const DECIMAL_METRIC_KEYS = new Set([
'cumulativeLayoutShift',
'cumulativeLayoutShiftAllFrames',
'cumulativeLayoutShiftMainFrame',
'oldCumulativeLayoutShift',
'observedCumulativeLayoutShift',
'observedCumulativeLayoutShiftAllFrames',
'layoutShiftAvgSessionGap5s',
'layoutShiftMaxSessionGap1s',
'layoutShiftMaxSessionGap1sLimit5s',
'layoutShiftMaxSliding1s',
'layoutShiftMaxSliding300ms',
'layoutShiftMaxSessionGap1sLimit5sAllFrames',
'observedCumulativeLayoutShiftMainFrame',
'observedOldCumulativeLayoutShift',
]);

class Metrics extends Audit {
Expand Down
10 changes: 5 additions & 5 deletions lighthouse-core/audits/metrics/cumulative-layout-shift.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ class CumulativeLayoutShift extends Audit {
*/
static async audit(artifacts, context) {
const trace = artifacts.traces[Audit.DEFAULT_PASS];
const metricResult = await ComputedCLS.request(trace, context);
const {cumulativeLayoutShift, ...rest} = await ComputedCLS.request(trace, context);

/** @type {LH.Audit.Details.DebugData} */
const details = {
type: 'debugdata',
items: [metricResult.debugInfo],
items: [rest],
};

return {
score: Audit.computeLogNormalScore(
{p10: context.options.p10, median: context.options.median},
metricResult.value
cumulativeLayoutShift
),
numericValue: metricResult.value,
numericValue: cumulativeLayoutShift,
numericUnit: 'unitless',
displayValue: metricResult.value.toLocaleString(context.settings.locale),
displayValue: cumulativeLayoutShift.toLocaleString(context.settings.locale),
details,
};
}
Expand Down
200 changes: 0 additions & 200 deletions lighthouse-core/computed/layout-shift-variants.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit b38fd27

Please sign in to comment.