Skip to content

Commit

Permalink
core: update cumulative-layout-shift (#12554)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored May 25, 2021
1 parent d882612 commit 3d090b5
Show file tree
Hide file tree
Showing 17 changed files with 609 additions and 1,017 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',
totalCumulativeLayoutShift: '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',
'totalCumulativeLayoutShift',
'observedCumulativeLayoutShift',
'observedCumulativeLayoutShiftAllFrames',
'layoutShiftAvgSessionGap5s',
'layoutShiftMaxSessionGap1s',
'layoutShiftMaxSessionGap1sLimit5s',
'layoutShiftMaxSliding1s',
'layoutShiftMaxSliding300ms',
'layoutShiftMaxSessionGap1sLimit5sAllFrames',
'observedCumulativeLayoutShiftMainFrame',
'observedTotalCumulativeLayoutShift',
]);

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 3d090b5

Please sign in to comment.