Skip to content

New Core Web Vitals and How They Work

New Core Web Vitals and How They Work

Core Web Vitals, introduced by Google in 2020, have been around for a while now. And after four years, a significant change is coming in March 2024. In this article, I will try to tell you everything you need to know to be prepared. But first, let's briefly talk about what Core Web Vitals are.

What are Core Web Vitals?

Web Vitals is a Google initiative that aims to provide developers with guidance on authoring the best user experience on the web as well as tools to assess and measure it. Core Web Vitals are a subset of Web Vitals and currently consist of three main metrics:

  • Largest Contentful Paint (LCP): This metric measures the time it takes for the largest content element to be rendered on the screen. It should reflect the loading aspect of the user experience.
  • First Input Delay (FID): This metric measures the time it takes for the browser to respond to the first user interaction. It should reflect the interactivity aspect of the user experience.
  • Cumulative Layout Shift (CLS): This metric measures the amount of unexpected layout shifts of visual elements on the page. It should reflect the visual stability aspect of the user experience.

Part of the Core Web Vitals are also the thresholds that define what is considered a good experience. These thresholds are currently set to:

MetricGoodNeeds ImprovementBad
LCP≤ 2.5 s2.5 - 4 s> 4 s
FID≤ 100 ms100 - 300 ms> 300 ms
CLS≤ 0.10.1 - 0.25> 0.25

While the reward of providing a good user experience should be enough for you to strive for great results in these metrics, that is not the only reason you should care about them. Google is reflecting these metrics in its search ranking algorithm as it wants it to "reward content that offers good user experience".

What's Changing in March 2024?

The change affects how interactivity is measured. The First Input Delay (FID) has been deemed no longer sufficient to measure the interactivity aspect of the user experience. It will be replaced by the Interaction to Next Paint (INP) metric on March 12, 2024.

INP, unlike FID, measures the response of all interactions up to a URL change. It then picks the slowest response from all interactions. (If there are more than 50 interactions, it picks a percentile instead, most often the 98th) making it much stricter than FID.

Why the Change?

There are three main reasons why FID is being replaced by INP:

  1. FID is not strict enough: Upwards of 90% of websites meet the good threshold for FID nowadays, making it a poor differentiator between good and bad user experiences.
  2. FID is not representative of the full interaction: FID only measures the first part of the reaction delay, up to the point before the response bubbles to JavaScript, not accounting for the (often quite long) time it takes for the JavaScript to process the response and for the browser to paint the next frame.
  3. FID only measures the first interaction: According to Google, 90% of interactions happen after the first load, making FID not representative of the full user experience.

INP aims to address these issues by measuring the full interaction and by being stricter in its thresholds (according to Google, ~70% of websites should pass the good INP threshold now) and thus capturing a more representative picture of the user experience.

How Does INP Work?

As I previously mentioned, INP measures all interactions on the page and picks the slowest one or a percentile, which solves one of the issues with FID not representing the whole experience of interacting with a website. This way of measuring is not dissimilar to how CLS measures the unexpected layout shifts on the page as it also captures the full scope of the stay on the page.

The interactions considered by INP are:

  • Mouse clicks
  • Touchscreen taps
  • Keyboard presses (including virtual onscreen keyboards)

If an interaction is composed of multiple events, such as a keystroke, consisting of the keydown, keypress, and keyup events; INP groups them and measures the latency as the maximum duration of all the included events.

Unlike FID, it captures not only the time taken by tasks blocked by the main thread (the input delay) but also the processing time (events and JavaScript processing) and the presentation delay (the time it takes for the browser to paint the next frame), making it a much better reflection of the full user experience, but also much harder to pass.

So while FID reflects the first impression, INP should capture the overall responsiveness of a page.

For more information about interactions with comprehensive diagrams of what actually happens in the browser, check out the web.dev article on INP.

Google defined the thresholds for INP as follows:

MetricGoodNeeds ImprovementBad
INP≤ 200 ms200 - 500 ms> 500 ms

How to Prepare for INP?

Let's start with some general steps you should take to prepare for the new Web Vital:

1. Measure

Start with measuring your INP score. The easiest way to measure it is using PageSpeed Insights, but if you need to measure it locally, you can use Lighthose user flows which already support INP. If your INP scores are good, you're fine and you can probably stop reading further.

2. Do not panic

While, according to Tim Kadlec, only 17% of React websites and 11.8% of Next.js websites in the "top 100k" pass the good INP threshold, so it's very likely that you will have to do some work to pass; framework authors have been working on improving their performance and things may be as hot as Tim paints them. According to Google’s stats, ~80-90% of desktop sites pass the good INP threshold depending on the framework as of June 2023:

TechnologyPassing on Mobile [%]Passing on Desktop [%]
Angular (v2.0.0+)28.683.6
Next.js28.587.3
Nuxt.js32.091.2
Preact48.692.8
Vue (v2.0.0+)50.394.1
Lit50.088.3

3. Optimize

In case your INP scores are not good, you should start optimizing your website. Identify the pages that perform the worst and start with them. Focus on:

  • Code splitting and tree shaking to make sure only the necessary JavaScript is included.
  • Deferring non-critical JavaScript events until the main thread is idle. Consider also offloading heavy tasks to a Web Worker.
  • Debouncing or throttling frequently fired events.
  • Breaking up long JavaScript tasks into smaller ones.
  • Using passive event listeners.
  • Reducing the presentational delay e.g. by using the will-change CSS property, and preferring transform and opacity over the display and position properties in animations.
  • Eliminating third-party scripts. Very often, third-party scripts, be it for analytics, cookie consent, or other purposes, have a significant impact on performance. Considering which of them are not absolutely necessary, and either removing them or replacing them with a more performant solution is highly recommended.
  • Upgrading your dependencies to make sure you are taking advantage of the latest performance-improving features.

If you want to read more about the general INP optimization tips, you can check out this Vercel article.

While a lot of these optimizations, such as code splitting and tree shaking, are already taken care of by modern frameworks, I believe that it’s worth going through this list to see what you can do to make your website faster and thus a better experience for your users. We will explore concrete performance tips for popular frameworks in the next article.

Conclusion

The change in Core Web Vitals is coming and it's going to be a significant one. The new metric, Interaction to Next Paint, is going to be much stricter than the current First Input Delay and it's going to be much harder to pass. However, the good news is that framework authors have already been working on making the frameworks more INP-friendly, and while it may take some effort, you should be able to improve your INP score.

INP, however, should not be just another Lighthouse threshold we have to satisfy. This change should encourage us to look beyond surface-level metrics and dive deeper into the nuances of user interaction. As we adapt to these changes, our focus should remain on the end goal: creating a good and inclusive user experience for our visitors.