new PerformanceObserver((list) => {
for (const { sources } of list.getEntries()) {
if (sources) {
const attribution = sources[0];
const json = attribution.toJSON();
console.log(json); // A plain object
console.log(typeof json); // "object"
console.log(json.previousRect.x); // Same value as attribution.previousRect.x
}
}
}).observe({ type: "layout-shift", buffered: true });LayoutShiftAttribution: toJSON() method / notebook
LayoutShiftAttribution: toJSON() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
console.log(JSON.stringify(attribution));