Interaction to Next Paint (INP) is a Core Web Vital metric that impacts Google search rankings. As web developers and website owners work to optimize their sites, some misconceptions about INP emerge.
This post addresses such misconceptions, and provides clear guidance on how INP works.
Are there misconceptions about INP?
INP is well documented. For some common user interactions, especially when you're testing locally, it's generally straightforward to understand how INP works: You click the 'add to cart' button, and the cart updates with a new product. The time between your click and the cart update is the INP.
However our Real User Monitoring customers would often find results that didn't align with their expectations.
- Why is INP so high for a seemingly simple interaction? It runs smoothly on my local machine.
- Why is this slow INP score showing that the user clicked on a paragraph element? It doesn't have any event listeners attached to it!
- I've profiled all my website code and it's optimized, and even runs well on low-end devices. Why is INP still high?
These are some of the questions that we set out to answer in this post.
Misconception 1: Visual Updates Are Required for INP
Some assume that INP waits for the visual update that follows an interaction. While a visual update does often follow an interaction, it's not a requirement for INP measurement.
In the following diagram, both scenarios involve user interactions, but only one scenario results in a visual update. Both scenarios trigger INP.
The Truth About INP and Visual Updates
Contrary to the "next paint" in its name, INP doesn't require visual updates to measure interaction delays.
INP measures the time between a user interaction and the next frame render, regardless of visual changes. It's more about rendering opportunities, rather than visual UI changes.
You can play around with this Interaction to Next Paint playground and learn more about what interactions can trigger INP. For example, you can click/tap on the header and notice an INP score is still reported, even though no visual update is needed in response to the click/tap interaction.
How to fix slow INP scores where there's no expected visual update
If you're getting slow INP scores for interactions that don't require visual updates, you likely have slow main thread tasks that are blocking the next frame render. In this case, you should work towards the recommendations listed in total blocking time to improve INP scores:
- Record a DevTools Performance profile to identify what main thread activity is happening during the user interaction.
- Focus on optimizing the main thread work that's causing the delay. This could involve breaking up long-running tasks, or moving client side work to the server.
While this could be a whole other misconception in itself, note that this post intentionally uses terms like "main thread work" rather than just "JavaScript work" to emphasize that INP is affected by all main thread tasks, not just JavaScript. In fact, you can get slow INP scores from interactivity without JavaScript.
The following screenshot shows heavy rendering activity from a user interaction, however no JavaScript is involved:
Misconception 2: Only Interactive Elements Affect INP
A common belief is that INP only applies to elements with event listeners, or elements that have visible responses to interactions.
For example it's understandable to think how a button click or form submission could affect INP, but what about a button click on a static paragraph element?
The Reality of INP and Page Elements
Any element on your page can influence INP scores, including seemingly inert elements like paragraphs. Background tasks and overall page performance play a big role in INP, regardless of the element interacted with.
For instance, clicking on a <p>
tag without any attached event listeners can still result in poor INP if there is still a lot of main thread work happening on the page.
<p>
This paragraph has no event listeners, but clicking it can still affect INP.
</p>
<script>
// Long-running task that can affect the INP score
function longRunningTask() {
for (let i = 0; i < 1000000; i++) {
// Simulating heavy computation
}
}
setInterval(longRunningTask, 100);
</script>
You may be wondering: why might a user click on a static paragraph? This is a common question we get from our Real User Monitoring customers. Users can interact with a page in unexpected ways. In the context of an inert paragraph, consider the following scenarios:
- A user accidentally taps on the paragraph while scrolling.
- A user performs a long-press on a word within a paragraph, expecting a context menu.
- A user performs a long-press on the paragraph to form a text selection, so they can copy the content.
- A user taps on the paragraph to test if the page is responsive.
- A user happens to click on the paragraph so that the page gains focus and they begin tabbing through the page.
The takeaway here is that any part of a page can impact INP, not just interactive elements.
How to fix slow INP scores for non-interactive elements
The fixes here involve similar fixes to improve general page performance:
- Minimize main thread work to ensure the browser can handle user interactions smoothly.
- Optimize recurring tasks, for example those through
setInterval
orsetTimeout
, as their execution may coincide with user interactions which can affect INP. - Use requestIdleCallback to schedule non-essential tasks during idle periods, rather than during user interactions.
Misconception 3: Only Your Own Website Code Impacts INP
It's easy to assume that your own website code is the sole factor in INP performance. Surely the battery life and device temperature of the user's device can't affect INP, right?
In reality, INP can be affected by battery life, device performance and much more.
Your website code might be very performant, but if your user's device is thermal throttling because it's overheating, and maybe couple that with a low battery, then the INP score could be impacted as the operating system tries to conserve power, which can slow down the device.
Not all examples have to be aligned with extremes, or edge cases. Here are some common external factors that can impact INP:
Third-Party Scripts can affect INP
External scripts can introduce delays that impact INP, even if they're not directly related to user interactions.
Some external scripts can attach event listeners to all elements on the page - for tracking purposes.