Created
February 4, 2026 18:25
-
-
Save victor-homyakov/b570f07d375dd73b95eb2bd17f26a825 to your computer and use it in GitHub Desktop.
View CLS performance entries
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (new PerformanceObserver((list) => { | |
| const entries = list.getEntriesByType('layout-shift'); | |
| entries.forEach((/*LayoutShift*/entry) => { | |
| console.log(entry); | |
| const /*Array<LayoutShiftAttribution>*/sources = entry.sources || []; | |
| const changes = []; | |
| for (const source of sources) { | |
| const { currentRect: cr, previousRect: pr, node } = source; | |
| const dx = cr.x - pr.x; | |
| const dy = cr.y - pr.y; | |
| const ds = cr.width * cr.height - pr.width * pr.height; | |
| changes.push({dx, dy, ds, node}); | |
| } | |
| if (changes.length) { | |
| console.table(changes); | |
| } | |
| }); | |
| })).observe({ type: 'layout-shift', buffered: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment