This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The LayoutShiftAttribution interface provides debugging information about elements which have shifted.
Instances of LayoutShiftAttribution are returned in an array by calling LayoutShift.sources.
LayoutShiftAttribution.node Read only Experimental
Returns the element that has shifted (null if it has been removed).
LayoutShiftAttribution.previousRect Read only Experimental
Returns a DOMRectReadOnly object representing the position of the element before the shift.
LayoutShiftAttribution.currentRect Read only Experimental
Returns a DOMRectReadOnly object representing the position of the element after the shift.
LayoutShiftAttribution.toJSON() Experimental
Returns a JSON representation of the LayoutShiftAttribution object.
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.
function getCLSDebugTarget(entries) {
const largestEntry = entries.reduce((a, b) =>
a && a.value > b.value ? a : b,
);
if (largestEntry?.sources?.length) {
const largestSource = largestEntry.sources.reduce((a, b) => {
const area = (el) => el.previousRect.width * el.previousRect.height;
return a.node && area(a) > area(b) ? a : b;
});
if (largestSource) {
return largestSource.node;
}
}
}
| Specification |
|---|
| Layout Instability API> # sec-layout-shift-attribution> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
LayoutShiftAttribution |
84 | 84 | No | 70 | No | 84 | No | 60 | No | 14.0 | 84 | No |
currentRect |
84 | 84 | No | 70 | No | 84 | No | 60 | No | 14.0 | 84 | No |
node |
84 | 84 | No | 70 | No | 84 | No | 60 | No | 14.0 | 84 | No |
previousRect |
84 | 84 | No | 70 | No | 84 | No | 60 | No | 14.0 | 84 | No |
toJSON |
84 | 84 | No | 70 | No | 84 | No | 60 | No | 14.0 | 84 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/LayoutShiftAttribution