Skip to content

Conversation

@anediaz
Copy link

@anediaz anediaz commented Nov 27, 2025

Description

Updates the LayoutShiftAttribution interface documentation to reflect the standardization of impact-area ordering for LayoutShift.sources, as implemented in Chrome 143.

Motivation

The Chromium team has defined a standardized ordering for LayoutShiftAttribution entries based on impact area to ensure consistent and predictable behavior across browser implementations.
This documentation update helps developers understand how layout shift sources are ordered and what behavior they can reliably expect when using the Performance API to analyze layout shifts.

Additional details

Related issues and pull requests

N/A

@anediaz anediaz requested a review from a team as a code owner November 27, 2025 07:56
@anediaz anediaz requested review from sideshowbarker and removed request for a team November 27, 2025 07:56
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Nov 27, 2025
- : Returns a JSON representation of the `LayoutShiftAttribution` object.

## Examples
The following example observes layout shifts and identifies the most impactful element. The `sources` array is sorted by impact area in descending order, so the first element (`sources[0]`) represents the element that contributed most to the layout shift. For more detail on this see [Debug Web Vitals in the field](https://web.dev/articles/debug-performance-in-the-field).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
The following example observes layout shifts and identifies the most impactful element. The `sources` array is sorted by impact area in descending order, so the first element (`sources[0]`) represents the element that contributed most to the layout shift. For more detail on this see [Debug Web Vitals in the field](https://web.dev/articles/debug-performance-in-the-field).

The following example observes layout shifts and identifies the most impactful element. The `sources` array is sorted by impact area in descending order, so the first element (`sources[0]`) represents the element that contributed most to the layout shift. For more detail on this see [Debug Web Vitals in the field](https://web.dev/articles/debug-performance-in-the-field).

The following example finds the element with the highest layout shift score, and returns the element in that entry with the largest size prior to the shift (`previousRect`). For more detail on this see [Debug Web Vitals in the field](https://web.dev/articles/debug-performance-in-the-field).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
The following example observes layout shifts and identifies the most impactful element. The `sources` array is sorted by impact area in descending order, so the first element (`sources[0]`) represents the element that contributed most to the layout shift. For more detail on this see [Debug Web Vitals in the field](https://web.dev/articles/debug-performance-in-the-field).

Comment on lines +35 to +47
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (!entry.sources || entry.sources.length === 0) continue;

const mostImpactfulSource = entry.sources[0];
console.log("Layout shift score:", entry.value);
console.log("Most impactful element:", largestShiftSource.node);
console.log("Previous position:", largestShiftSource.previousRect);
console.log("Current position:", largestShiftSource.currentRect);
}
}
}
});

observer.observe({ type: "layout-shift", buffered: true });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[mdn-linter] reported by reviewdog 🐶

Suggested change
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (!entry.sources || entry.sources.length === 0) continue;
const mostImpactfulSource = entry.sources[0];
console.log("Layout shift score:", entry.value);
console.log("Most impactful element:", largestShiftSource.node);
console.log("Previous position:", largestShiftSource.previousRect);
console.log("Current position:", largestShiftSource.currentRect);
}
}
}
});
observer.observe({ type: "layout-shift", buffered: true });
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
if (!entry.sources || entry.sources.length === 0) continue;
const mostImpactfulSource = entry.sources[0];
console.log("Layout shift score:", entry.value);
console.log("Most impactful element:", largestShiftSource.node);
console.log("Previous position:", largestShiftSource.previousRect);
console.log("Current position:", largestShiftSource.currentRect);
}
});
observer.observe({ type: "layout-shift", buffered: true });

@sideshowbarker
Copy link
Member

Howdy — this has linter failures that need to be resolved.

@sideshowbarker sideshowbarker added the awaiting response Awaiting for author to address review/feedback label Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting response Awaiting for author to address review/feedback Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants