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 hadRecentInput read-only property of the LayoutShift interface returns true if lastInputTime is less than 500 milliseconds in the past.
Layout shifts are only a problem if the user is not expecting them, so layout shifts that are the result of user interactions (such as a user expanding a UI element) are often not considered in layout shift metrics. The hadRecentInput property allows you to exclude these shifts.
A boolean returning true if lastInputTime is less than 500 milliseconds in the past; false otherwise.
The following example shows how the hadRecentInput property is used to only count layout shifts without recent user input.
const observer = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
// Count layout shifts without recent user input only
if (!entry.hadRecentInput) {
console.log("LayoutShift value:", entry.value);
if (entry.sources) {
for (const { node, currentRect, previousRect } of entry.sources)
console.log("LayoutShift source:", node, {
currentRect,
previousRect,
});
}
}
}
});
observer.observe({ type: "layout-shift", buffered: true });
| Specification |
|---|
| Layout Instability API> # dom-layoutshift-hadrecentinput> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
hadRecentInput |
77 | 79 | No | 64 | No | 77 | No | 55 | No | 12.0 | 77 | 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/LayoutShift/hadRecentInput