Home  ›  Blog

Why JavaScript-Heavy Frameworks Destroy Your Core Web Vitals (And How to Fix It Without Rewriting Your Code)

A JavaScript-heavy page slowing down Core Web Vitals
The framework is not slow — the work before the first paint is.

A client once showed us a site that looked fast on his laptop and failed every Core Web Vitals check in Search Console. The design was fine. The hosting was fine. The problem was the page itself: a JavaScript framework was downloading, parsing and running hundreds of kilobytes of code before the visitor could read a headline or tap a button. The site was not broken. It was busy.

This is the most common speed problem we see, and the most misunderstood. People blame the server, the images or the hosting, while the real culprit sits in the page: too much JavaScript, doing too much work, too early. Most of it can be fixed without rewriting the site — but first you have to understand the mechanism, because each of the three Core Web Vitals breaks for a different reason.

The diagnosis: three numbers, three different complaints

Core Web Vitals are three measurements Google takes from real Chrome users, and a page passes only when all three are good at the 75th percentile of visits — three out of four real visits clearing the bar, separately for mobile and desktop. The thresholds are fixed and public: LCP of 2.5 seconds or less, INP of 200 milliseconds or less, and CLS of 0.1 or less. Above those you are in "needs improvement"; above 4 seconds, 500 milliseconds and 0.25 respectively, "poor". INP replaced First Input Delay as the responsiveness metric in March 2024.

The first step is to find out which of the three is failing, because they point at different parts of the page. LCP is a loading complaint: the biggest thing on screen takes too long to appear. INP is a responsiveness complaint: the visitor taps and the page reacts too slowly. CLS is a stability complaint: content jumps while the page settles. A framework-heavy page often fails all three, but the fixes differ, and fixing the wrong one first wastes a week.

Remember the difference between lab data and field data. Lighthouse loads your page once under simulated conditions — useful for debugging, but not what Google ranks on. The field data comes from the Chrome User Experience Report, a rolling 28-day window of real Chrome visits, and that is what feeds Search Console. A page can pass Lighthouse and still fail in the field, because real visitors are on mid-range phones and patchy connections.

The mechanism: where the milliseconds actually go

A JavaScript framework does not slow a page down by existing. It slows it down through four mechanisms, each mapping to a metric.

The first is bundle size. When a page is built as a single-page app, the browser often has to download the framework, the router, the state library and every component before it can render anything. On a slow connection that download alone can eat the whole LCP budget. The second is hydration. In a server-rendered page, the server sends finished HTML — and then the framework downloads its JavaScript and re-attaches event handlers to every element. Until hydration finishes, buttons look clickable and are not, and INP suffers. Hydration is the hidden cost of server rendering: you pay for the page twice, once as HTML and once as JavaScript.

The third mechanism is long tasks. JavaScript runs on a single main thread, and while a script is running, the browser cannot respond to taps or paint updates. A task that runs for more than about 50 milliseconds is a long task, and a framework that parses a large data set or renders a long list on load will block the thread in long chunks. Every tap that lands during a long task waits, and that wait is exactly what INP measures. The fourth mechanism is layout shift from late content: fonts that swap in after the text has rendered, images without reserved space, and components that appear only after JavaScript fetches data. That is CLS, and it is usually caused by something the framework does after the first paint rather than before it.

Measuring Core Web Vitals on a mobile phone
Measure on a real phone — the field data is what Google counts.

The fix playbook: no rewrite required

None of the fixes below requires changing frameworks or rebuilding the site — only changing how much JavaScript runs, and when.

import { lazy, Suspense } from "react";
const HeavyChart = lazy(() => import("./HeavyChart"));

<Suspense fallback={<p>Loading chart…</p>}>
  <HeavyChart />
</Suspense>

The chart code is not in the first bundle at all — it downloads only when the dashboard renders. The same dynamic-import pattern exists in every major framework, and it is the single highest-value change on most sites we fix.

Next, cut hydration where it is not needed. Large parts of most pages never need to be interactive: the header, the footer, the marketing copy. In frameworks that support it, those sections can be rendered as static HTML with no JavaScript attached at all — islands of interactivity, where only the genuinely interactive pieces hydrate. Otherwise, use lazy hydration: attach handlers only when the visitor scrolls near a component. A carousel below the fold does not need to be interactive before the visitor sees it.

Then fix the images and fonts: explicit width and height on every image so the browser reserves its space, the hero preloaded at its displayed size, fonts on font-display: swap with only the weights the page uses, and third-party scripts deferred until after the page is interactive.

CheckBeforeAfter
Bundle per routeOne bundle for the whole appSplit by route; heavy components lazy-loaded
HydrationWhole page hydrates on loadStatic sections stay static; below-fold hydrates late
ImagesNo dimensions; full-size filesWidth and height set; right size and format; hero preloaded
FontsAll weights, blocking renderUsed weights only, font-display: swap
Third-party scriptsChat, analytics and embeds load firstDeferred until after first interaction
Long tasksHeavy work on the main threadSplit into chunks; heavy work moved off the main thread

How to measure whether it worked

Fixes without measurement are guesses, so measure in the right order. First, run Lighthouse in Chrome DevTools on the changed page and look at the opportunities list, not the headline score — it names the specific scripts and images that cost the most time. Then run the same page through PageSpeed Insights and read the field data section: that is the 28-day CrUX picture, and it is the number that matters for Search Console. Expect the field data to lag behind your fix by days, because it is a rolling window over real visits, not a live reading.

For INP specifically, lab tools are not enough, because INP only exists when a real person interacts. The practical fix is real-user measurement: the small web-vitals library reports LCP, INP and CLS from actual visits to your own analytics, so you can see the 75th percentile per page, on mobile separately from desktop. Give it a week of real traffic before deciding the next fix.

One honest note: a 0.8-second page speed is a build target we set for our own pages, not a measured result we claim for every site. The thresholds that matter are Google's — LCP 2.5 seconds, INP 200 milliseconds, CLS 0.1 — and the goal is to pass them in the field, on real phones. Read how we achieve sub-0.8s page speeds on the edge for the full story of how we build fast pages from the start.

What to do next

Open Search Console, find the Core Web Vitals report, and write down which metric fails on which pages — that list is the whole brief. Then work the playbook in order: split the bundle, cut hydration, fix images and fonts, defer third-party scripts, and measure again in the field. If you would rather hand it over, we do this as part of our website speed optimization and custom web development work. Get an instant estimate or send us the failing URL on WhatsApp.