How to optimize core web vitals

How to optimize core web vitals

Customer Experience (CX)
Insight
Milan Matic
MM

Milan Matic

UX Engineer | Senior Frontend Engineer

9 min read

Learn practical, high-impact optimisations for LCP, INP, and CLS with a clear checklist: image strategy, critical CSS, JavaScript discipline, caching, and real-user monitoring.

Web Core Vitals are real-user performance metrics that strongly influence perceived speed and overall UX. The current key metrics are:

  • LCP (Largest Contentful Paint): how quickly the main content becomes visible.
  • INP (Interaction to Next Paint): how responsive the page feels when users interact.
  • CLS (Cumulative Layout Shift): how stable the layout is while loading.

This guide focuses on changes that typically move the needle fast, and how to verify you've actually improved things in the real world.


1) Start with measurement that reflects reality

Before optimising, establish a baseline:

  • Lab tools: Lighthouse / PageSpeed Insights to reproduce issues.
  • Real-user monitoring (RUM): collect field data from actual visitors.

A good workflow:

  1. Identify the page templates that matter (home, listing, product/article).
  2. Measure them on mobile (throttled CPU/network in lab).
  3. Confirm with field data if available.

Tip: Lab scores are useful to diagnose why. Field data is what you ship for.


2) Optimise LCP (make the main content appear sooner)

Prioritise the LCP element

Your LCP is often a hero image, headline block, or product image.

  • Preload the LCP image (or the critical font if it blocks rendering).
  • Avoid lazy-loading the above-the-fold hero.
  • Serve modern formats (AVIF/WebP) with responsive sizes.

Example (HTML):

<link rel="preload" as="image" href="/images/hero-1280.webp" imagesrcset="/images/hero-640.webp 640w, /images/hero-1280.webp 1280w" imagesizes="100vw" />
<img
  src="/images/hero-1280.webp"
  srcset="/images/hero-640.webp 640w, /images/hero-1280.webp 1280w"
  sizes="100vw"
  width="1280"
  height="720"
  alt="Hero"
  fetchpriority="high"
/>

Reduce server and CDN latency

  • Use a CDN for static assets.
  • Enable compression (Brotli/Gzip).
  • Use HTTP caching aggressively for hashed assets.

Cache headers for fingerprinted assets:

Cache-Control: public, max-age=31536000, immutable

Kill render-blocking CSS

  • Inline critical CSS for above-the-fold.
  • Defer non-critical CSS.
  • Remove unused CSS (common with large UI libraries).

3) Improve INP (make interactions feel instant)

INP suffers when the main thread is busy.

Audit JavaScript like it's a budget

  • Split bundles by route.
  • Avoid shipping heavy libraries for small features.
  • Prefer server-rendered or partial hydration where possible.

Defer non-essential work

  • Load analytics after interaction or after load.
  • Delay non-critical widgets.

Example (defer a module):

window.addEventListener("load", async () => {
  const { initChatWidget } = await import("./chat-widget.js");
  initChatWidget();
});

Break up long tasks

If you have JS tasks that run for 100–300ms+, split them:

  • Use requestIdleCallback when safe.
  • Chunk work into smaller pieces.

4) Fix CLS (stop the page from jumping)

CLS is usually caused by late-loading content changing layout.

Always reserve space

  • Set explicit width and height on images.
  • Use aspect-ratio for media containers.
.hero-media {
  aspect-ratio: 16 / 9;
}

Handle fonts correctly

  • Use font-display: swap.
  • Preload critical fonts.
  • Prefer system font stack if you can.

Avoid injecting UI above existing content

Cookie banners, promo bars, and consent modals often push content down.

  • Render them in a reserved slot.
  • Or overlay them instead of shifting layout.

5) A practical checklist (high ROI)

Fast wins (often same day)

  • Ensure hero/LCP image is not lazy-loaded
  • Add correct image sizing + modern formats
  • Inline critical CSS; defer the rest
  • Remove unused CSS and reduce font variants
  • Defer analytics and heavy third-party scripts
  • Reserve space for images, embeds, banners

Deeper wins (1–2 sprints)

  • Route-based code splitting + reduce JS shipped
  • Partial hydration / islands architecture
  • Server response time improvements + caching strategy
  • RUM dashboards and alerting for regressions

6) Verify improvements the right way

After each change:

  1. Re-test in lab to confirm the suspected bottleneck improved.
  2. Track field metrics to ensure it holds across devices and networks.
  3. Watch for regressions from third-party scripts and new UI components.

Optimising Web Core Vitals is mostly about discipline:

  • LCP: prioritise the main content and remove render blockers.
  • INP: protect the main thread and ship less JavaScript.
  • CLS: reserve space and avoid layout surprises.

Do the fast wins first, measure, then iterate where the data proves it matters most.

GlobalCore Website

Share: Back to articles

Related Articles

Ready to transform your business?

Get in touch with our team to discuss how we can help you achieve your goals.