Square CloudSquare Cloud

Core Web Vitals: LCP, INP and CLS explained

Core Web Vitals are three Google metrics for the real experience of a page: LCP (loading), INP (responsiveness) and CLS (visual stability). Good means LCP up to 2.5 s, INP up to 200 ms and CLS up to 0.1, at the 75th percentile of visits.

Updated 8 min read

Learning objectives

After reading this article you will be able to:

  • Understand what LCP, INP and CLS measure and which values count as good
  • Tell field data (real visits) apart from lab data (Lighthouse)
  • Know what the server influences and what depends on the front end alone
On this page

A page can sit on a fast server and still feel slow: the hero image takes ages to show up, a button ignores the tap, the text jumps when an ad loads. Core Web Vitals turn those impressions into numbers you can compare and track.

They are three metrics defined by Google and measured in the visitor's browser. Knowing what each one measures keeps you from optimizing the wrong part of the site.

What are Core Web Vitals?#

Core Web Vitals are the three metrics Google uses to sum up the experience of a page: loading (LCP), responsiveness (INP) and visual stability (CLS). The thresholds, according to web.dev:

Metric What it measures Good Needs improvement Poor
LCP (Largest Contentful Paint) When the largest visible element finishes rendering up to 2.5 s 2.5 to 4 s over 4 s
INP (Interaction to Next Paint) How long the page takes to show a response to clicks, taps and key presses up to 200 ms 200 to 500 ms over 500 ms
CLS (Cumulative Layout Shift) How much content moves without the user asking up to 0.1 0.1 to 0.25 over 0.25

The assessment doesn't use the average. It looks at the 75th percentile of visits, with mobile and desktop counted separately: if three out of four page loads stay within the threshold, the metric is good. A page passes only when all three are good. It's the same idea as p95 latency: the number that matters is what most people feel, not what your own laptop shows. INP took the place of FID, which only measured the delay of the first interaction.

How is LCP measured?#

The browser records the moment the largest element visible in the viewport finishes rendering. Candidates are images (<img> and <image> inside SVG), the poster or first frame of a <video>, elements with a url() background image and blocks of text. Measurement stops as soon as the user interacts with the page.

web.dev splits LCP into four parts, and knowing which one is heavy tells you where to act:

Part What it is Suggested share
TTFB From the start of navigation to the first byte of HTML about 40%
Resource load delay From the first byte until the browser starts fetching the LCP resource under 10%
Resource load duration Downloading the resource itself (the image, for example) about 40%
Element render delay From the end of the download until the element appears under 10%

Both "delay" parts should be close to zero. The classic mistake is putting loading="lazy" on the hero image: the browser only requests the file after working out the layout, and the load delay grows. For the image at the top, do the opposite and ask for high priority:

html
<img src="/img/hero.avif" width="1200" height="630" fetchpriority="high" alt="Product hero">

If the image is only referenced in CSS or JavaScript, the browser can't discover it from the HTML; a <link rel="preload"> in the <head> fixes that.

How is INP measured?#

INP watches clicks, taps and key presses during the whole visit. Scrolling, hovering and zooming don't count. Each interaction has three phases:

  1. Input delay: the time until event handlers start running, usually because the main thread was busy with another task.
  2. Processing duration: the time the handlers themselves take.
  3. Presentation delay: from the end of the handlers until the next frame is painted.

The reported value is the worst interaction of the visit. On pages with many interactions, one of the slowest is ignored for every 50, so a single outlier doesn't dominate. A poor INP almost always comes from JavaScript: long tasks on the main thread, handlers that do heavy work before updating the screen, and third-party scripts. The fix is to break the work into smaller pieces, show the visual response first and defer the rest.

How is CLS calculated?#

Each unexpected shift gets a score: the fraction of the viewport affected multiplied by the distance the element moved, relative to the viewport's larger dimension. Shifts less than 1 second apart form a session window of up to 5 seconds, and CLS is the total of the worst window. Shifts within 500 ms of a click, tap or key press don't count, because the user expected the change.

The most common causes, according to web.dev:

  • images and videos without width and height;
  • web fonts that render larger or smaller than the fallback font;
  • third-party ads and widgets that resize after loading;
  • content injected above what is already on screen, such as notice banners.

Field data or lab data: what's the difference?#

Field data comes from real visits. The public source is the Chrome UX Report (CrUX), which feeds Search Console and the top of PageSpeed Insights with the last 28 days. It only counts Chrome users who turned on usage statistics and history sync (Chrome on iOS is left out), and low-traffic pages don't make it in, so a new site may have no data at all.

Lab data comes from a controlled test such as Lighthouse, which simulates a mid-range device on a fixed network. It is useful for debugging and for comparing before and after a change, but it doesn't replace field data. A Lighthouse page-load test can't measure INP, because nobody clicks during the simulation; it reports Total Blocking Time (TBT) as a proxy instead.

Without CrUX data, collect the metrics in the visitor's browser with the web-vitals library, from the Chrome team. In a project with a bundler (Vite, webpack or your framework's own):

bash
npm install web-vitals
js
import { onCLS, onINP, onLCP } from "web-vitals";

function report(metric) {
  const body = JSON.stringify({
    name: metric.name,
    value: metric.value,
    rating: metric.rating, // "good", "needs-improvement" or "poor"
    id: metric.id,
    page: location.pathname,
  });
  // sendBeacon keeps working while the page is closing
  navigator.sendBeacon("/vitals", body);
}

onCLS(report);
onINP(report);
onLCP(report);

On the server, a route reads the body as text, which is the type sendBeacon uses for a string. In Express, with "type": "module" in package.json:

js
import express from "express";

const app = express();
app.use(express.static("dist")); // the site's build, with the script above

app.post("/vitals", express.text(), (req, res) => {
  const metric = JSON.parse(req.body);
  console.log(metric.name, metric.value, metric.rating, metric.page);
  res.sendStatus(204);
});

app.listen(process.env.PORT ?? 3000);

Store the values in a database and compute the 75th percentile per page, the way CrUX does.

What does the server influence?#

The server weighs mostly on LCP, through TTFB and the download of files. As a rough guide, web.dev suggests a TTFB of 0.8 s or less. It adds up redirects, DNS lookup, connection, TLS and the time until the response starts, so each item is a lever:

  • Fewer redirects: every hop before the HTML (from http to https, from an old URL to the new one) adds a round trip.
  • Caching: ready-made HTML, from a static site or a cached page, answers faster than a page built on every visit. See SSR vs SSG vs static and the Cache-Control header.
  • CDN: serving files from a point close to the visitor shortens every request (what is a CDN). Protocols like HTTP/3 cut the cost of opening the connection.
  • Compression: Brotli or Gzip on HTML, CSS and JavaScript shorten the load duration.
  • A server ready to answer: a process that has to "wake up" (cold start) or a slow database query shows up directly in TTFB.

INP and CLS, on the other hand, depend almost entirely on the front end: JavaScript on the main thread, space reserved for images, fonts and third-party scripts. The optimization steps are in how to speed up a website.

What don't Core Web Vitals measure?#

They measure the experience inside the browser. They don't tell you whether the site is up, whether the API returns errors or how many visits you got. Neighboring metrics such as FCP (first content on screen), TTFB and TBT help with diagnosis, but they are not part of the three.

A cookieless analytics tool that counts visits on the server sees routes, status codes and response time, but not what happens in the browser after the HTML arrives. For LCP, INP and CLS you need code running on the page (like web-vitals) or CrUX data.

In search, Google's ranking systems use Core Web Vitals, but good scores don't guarantee top positions. Treat the metrics as quality for your visitors, not as an SEO shortcut.

How to do this on Square Cloud#

On the server side, every Square Cloud plan includes a global Anycast CDN with more than 200 points of presence, HTTP/3 and automatic TLS. The CDN follows the Cache-Control your application sends, so your code decides how long each response stays cached. A static site is served by a web server that is always up, and applications stay on, with no sleep on inactivity. Database queries and page rendering, which also count toward TTFB, depend on your code.

Web analytics, included in every plan for applications published as a site, is collected on the server from HTTP traffic: visits, routes, countries, browsers and status codes, with no script on the page. Pro and Enterprise add p50, p95 and p99 latency at the edge and at the origin. It doesn't measure Core Web Vitals in the browser: for LCP, INP and CLS, use Search Console or the web-vitals library from the example above.

See runtimes, plans and limits on website hosting.

Website hosting

Static and SSR sites with automatic TLS and a global CDN

Website hosting

FAQs

Do Core Web Vitals affect Google rankings?

Yes. Google says its ranking systems use Core Web Vitals, but warns that good scores don't guarantee top positions and that the most relevant content still shows up even when its page experience is worse.

Why does PageSpeed Insights show different numbers from Lighthouse?

The top of the report shows field data from the Chrome UX Report, covering 28 days of real visits. The bottom is a Lighthouse lab test that simulates one device on one network. They measure different things and rarely match.

What happened to FID?

INP replaced FID as the responsiveness metric. FID measured only the input delay of the first interaction; INP watches every interaction in the visit and reports one of the slowest.

Why does my site have no field data?

The Chrome UX Report only includes pages and origins with enough traffic from eligible Chrome users. On smaller sites, collect the metrics yourself with the web-vitals library and send them to your server.

Is TTFB a Core Web Vital?

No. TTFB is a diagnostic metric, but it is part of LCP: all the time until the first byte of HTML counts toward loading. web.dev suggests 0.8 s or less as a rough guide.

Next articleHow to host a Next.js appTo host a Next.js app, run next build and next start on a server with Node.js, or generate a static export. See the steps, code and common errors.

More in Websites

See all 25 articles