-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
45 lines (31 loc) · 1.12 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
title: "LayoutShift: sources property"
short-title: sources
slug: Web/API/LayoutShift/sources
page-type: web-api-instance-property
status:
- experimental
browser-compat: api.LayoutShift.sources
---
{{SeeCompatTable}}{{APIRef("Performance API")}}
The **`sources`** read-only property of the {{domxref("LayoutShift")}} interface returns an array of {{domxref("LayoutShiftAttribution")}} objects that indicate the DOM elements that moved during the layout shift.
## Value
An {{jsxref("Array")}} of {{domxref("LayoutShiftAttribution")}} objects. This array will not contain more than five sources. If there are more than five elements impacted by the layout shift, the five most impactful elements are reported.
## Examples
### Logging layout shift sources
```js
const observer = new PerformanceObserver((list) => {
list.getEntries().forEach((entry) => {
entry.sources.forEach((source) => {
console.log(source);
});
});
});
observer.observe({ type: "layout-shift", buffered: true });
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("LayoutShiftAttribution")}}