Skip to content

Commit

Permalink
core: remove layout-shift-elements audit (#15931)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Apr 9, 2024
1 parent c1895ac commit c35b375
Show file tree
Hide file tree
Showing 61 changed files with 296 additions and 1,422 deletions.
2 changes: 1 addition & 1 deletion cli/test/fixtures/perf/delayed-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function stall(ms) {
}

// largest-contentful-paint-element: add the largest element later in page load
// layout-shift-elements: shift down the `<h1>` in the page
// layout-shifts: shift down the `<h1>` in the page
setTimeout(() => {
const imgEl = document.createElement('img');
imgEl.src = '../dobetterweb/lighthouse-480x318.jpg';
Expand Down
50 changes: 5 additions & 45 deletions cli/test/smokehouse/test-definitions/perf-trace-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,37 +80,6 @@ const expectations = {
},
type: 'image',
},
{
traceEventType: 'layout-shift-element',
node: {
selector: 'body > h1',
nodeLabel: 'Please don\'t move me',
snippet: '<h1>',
boundingRect: {
top: 465,
bottom: 502,
left: 8,
right: 404,
width: 396,
height: 37,
},
},
},
{
traceEventType: 'layout-shift-element',
node: {
nodeLabel: 'Sorry!',
snippet: '<div style="height: 18px;">',
boundingRect: {
top: 426,
bottom: 444,
left: 8,
right: 404,
width: 396,
height: 18,
},
},
},
{
traceEventType: 'layout-shift',
node: {
Expand Down Expand Up @@ -188,9 +157,9 @@ const expectations = {
],
},
},
'layout-shift-elements': {
'layout-shifts': {
score: 1,
displayValue: '2 elements found',
displayValue: '2 layout shifts found',
details: {
items: [
{
Expand All @@ -207,22 +176,13 @@ const expectations = {
height: 37,
},
},
score: '0.035 +/- 0.01',
score: '0.05 +/- 0.01',
},
{
node: {
nodeLabel: 'Sorry!',
snippet: '<div style="height: 18px;">',
boundingRect: {
top: 426,
bottom: 444,
left: 8,
right: 404,
width: 396,
height: 18,
},
nodeLabel: /Sorry|Please don't move me/,
},
score: '0.017 +/- 0.01',
score: '0.001 +/- 0.005',
},
],
},
Expand Down
101 changes: 0 additions & 101 deletions core/audits/layout-shift-elements.js

This file was deleted.

2 changes: 0 additions & 2 deletions core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ const defaultConfig = {
'third-party-facades',
'largest-contentful-paint-element',
'lcp-lazy-loaded',
'layout-shift-elements',
'layout-shifts',
'long-tasks',
'non-composited-animations',
Expand Down Expand Up @@ -483,7 +482,6 @@ const defaultConfig = {
{id: 'final-screenshot', weight: 0, group: 'hidden'},
{id: 'script-treemap-data', weight: 0, group: 'hidden'},
{id: 'resource-summary', weight: 0, group: 'hidden'},
{id: 'layout-shift-elements', weight: 0, group: 'hidden'},
],
},
'accessibility': {
Expand Down
19 changes: 0 additions & 19 deletions core/gather/gatherers/trace-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {TraceEngineResult} from '../../computed/trace-engine-result.js';

/** @typedef {{nodeId: number, animations?: {name?: string, failureReasonsMask?: number, unsupportedProperties?: string[]}[], type?: string}} TraceElementData */

const MAX_LAYOUT_SHIFT_ELEMENTS = 15;
const MAX_LAYOUT_SHIFTS = 15;

/**
Expand Down Expand Up @@ -66,22 +65,6 @@ class TraceElements extends BaseGatherer {
if (name) this.animationIdToName.set(id, name);
}

/**
* This function finds the top (up to 15) elements that shift on the page.
*
* @param {LH.Trace} trace
* @param {LH.Gatherer.Context} context
* @return {Promise<Array<{nodeId: number}>>}
*/
static async getTopLayoutShiftElements(trace, context) {
const {impactByNodeId} = await CumulativeLayoutShift.request(trace, context);

return [...impactByNodeId.entries()]
.sort((a, b) => b[1] - a[1])
.slice(0, MAX_LAYOUT_SHIFT_ELEMENTS)
.map(([nodeId]) => ({nodeId}));
}

/**
* We want to a single representative node to represent the shift, so let's pick
* the one with the largest impact (size x distance moved).
Expand Down Expand Up @@ -338,7 +321,6 @@ class TraceElements extends BaseGatherer {
const {mainThreadEvents} = processedTrace;

const lcpNodeData = await TraceElements.getLcpElement(trace, context);
const shiftElementsNodeData = await TraceElements.getTopLayoutShiftElements(trace, context);
const shiftsData = await TraceElements.getTopLayoutShifts(
trace, traceEngineResult, rootCauses, context);
const animatedElementData = await this.getAnimatedElements(mainThreadEvents);
Expand All @@ -347,7 +329,6 @@ class TraceElements extends BaseGatherer {
/** @type {Map<string, TraceElementData[]>} */
const backendNodeDataMap = new Map([
['largest-contentful-paint', lcpNodeData ? [lcpNodeData] : []],
['layout-shift-element', shiftElementsNodeData],
['layout-shift', shiftsData],
['animation', animatedElementData],
['responsiveness', responsivenessElementData ? [responsivenessElementData] : []],
Expand Down
Loading

0 comments on commit c35b375

Please sign in to comment.