Fix Core Web Vitals (LCP, CLS, INP) — Replit
Core Web Vitals are a ranking signal. Poor vitals cap ranking even if content and links are good. They also correlate directly with bounce rate and conversion.
Fixing this in Replit
Cloud IDE with Replit Agent
Replit Agent works best when you hand it a precise instruction and a scoped folder. Paste the prompt below into your Replit chat and the fix rolls out across the project in one pass.
Using a different tool? Pick your stack:
The prompt for Replit
Copy and paste this into your Replit chat exactly as-is.
In Replit, ask the Replit Agent to make these exact changes across the project: Improve Core Web Vitals 1. Lazy-load offscreen images with loading="lazy" and add explicit width/height to avoid layout shift. 2. Move large third-party scripts to async/defer or load them only after user interaction. 3. Inline critical CSS and preload the LCP image with <link rel="preload" as="image">.
Why this matters
Google introduced Core Web Vitals as a ranking factor in 2021 and replaced FID with INP in 2024. Pages that fail the thresholds are demoted in mobile results — not dramatically, but measurably, and the demotion compounds with other weak signals.
Beyond SEO, the three vitals correlate strongly with conversion rate. LCP above 4 seconds roughly doubles bounce rate on mobile. CLS above 0.25 causes users to click the wrong element during page load. INP above 500ms feels broken.
AI-built apps often ship with unoptimized hero images, 3 MB of unused JavaScript, and no width/height on images or iframes. All three torpedo vitals. Fortunately, all three fixes are straightforward.
How to use this prompt in Replit
- 1. Open your Replit project.
- 2. Copy the prompt above with the copy button.
- 3. Paste into the Replit chat and send.
- 4. Review the diff, accept the changes, redeploy.
- 5. Verify the fix using the checklist below.
Common mistakes to avoid
- error_outlineServing the hero image as a 3 MB JPEG without a `<link rel="preload">`.
- error_outlineUsing lazy-loading on the LCP image — it becomes slower, not faster.
- error_outlineMissing width and height on images, causing the page to jump as they load (CLS).
- error_outlineLoading analytics and chat widgets synchronously before interactive content.
- error_outlineRunning expensive computations on page load inside a useEffect with no splitting.
How to verify the fix worked
- check_circleRun https://pagespeed.web.dev/ on your page — Core Web Vitals assessment must be green.
- check_circleOpen Chrome DevTools → Lighthouse → Performance — targets: LCP ≤ 2.5s, CLS ≤ 0.1, INP ≤ 200ms.
- check_circleIn Google Search Console → Core Web Vitals report — no "Poor URLs" left.
- check_circleTest on real mobile (not emulated) with a 4G throttle.
Frequently asked questions
How much does passing Core Web Vitals lift ranking?expand_more
Do Core Web Vitals measure lab or field data?expand_more
What is the hardest vital to pass?expand_more
Want all 34 prompts tailored to your Replit site?
Pantra scans your site in 10 seconds, detects the stack, and generates the exact prompts that apply — only the ones you actually need.
Scan my siteRelated Replit prompts
Improve Largest Contentful Paint (LCP) — Replit
Prompt to get LCP under 2.5 seconds — preload the hero image, cut render-blocking, use a proper CDN.
PerformanceFix Cumulative Layout Shift (CLS) — Replit
Prompt to eliminate CLS — add width/height to images, reserve space for ads, avoid late-loading fonts.
PerformanceImprove Interaction to Next Paint (INP) — Replit
Prompt to get INP under 200ms — split long tasks, lazy-load heavy JS, debounce handlers.
ImagesConvert images to WebP or AVIF — Replit
Prompt to convert JPEG/PNG to WebP or AVIF — 30-50% smaller at the same quality. Helps LCP and CLS.