Failing Core Web Vitals is rarely solved by one compression setting or a single Lighthouse run. This guide gives you a repeatable JavaScript workflow for separating field data from lab data, identifying whether LCP, INP, or CLS is the problem, and choosing focused fixes for images, fonts, JavaScript, third-party code, caching, and server response time.
Overview
Core Web Vitals describe three user-facing aspects of page experience: loading, responsiveness, and visual stability. The three metrics are Largest Contentful Paint (LCP), Interaction to Next Paint (INP), and Cumulative Layout Shift (CLS).
| Metric | What it represents | Common “good” target | First questions to ask |
|---|---|---|---|
| LCP | How quickly the main content becomes visible | 2.5 seconds or less | What is the LCP element? Is the server, resource, or rendering work delaying it? |
| INP | How quickly the page responds to user interactions | 200 milliseconds or less | Which interaction is slow? Is JavaScript blocking the main thread? |
| CLS | How much visible content moves unexpectedly | 0.1 or less | Which element shifted, and did it lack reserved space? |
Use these values as an orientation point rather than a substitute for diagnosis. A page can pass one metric and fail another, and a score can vary by device, connection, route, template, and user behavior.
Start with field data when deciding whether a real-user problem is widespread. Field data reflects visits over time and can reveal issues that depend on a particular device or interaction. Use lab data from browser developer tools or a performance audit to reproduce a page under controlled conditions and inspect a trace. Lab data is excellent for debugging, but it may not match every visitor’s experience.
A useful workflow is: record the URL and release version, identify the failing metric, reproduce the issue, inspect the largest contributor, make one focused change, and measure again. Keep the change tied to a specific hypothesis.
Checklist by scenario
When LCP is slow
First identify the LCP element. It may be a hero image, heading, poster, or large block of text. In a browser performance trace, inspect when that element was requested, when its response arrived, and when it was painted.
- Check server response time: Review the initial document request, backend work, database queries, redirects, and cache status. A slow document delays discovery of stylesheets, scripts, fonts, and images.
- Prioritize the LCP resource: Do not lazy-load the primary above-the-fold image. Use an appropriately sized format, provide width and height, and make sure the resource can be discovered early. Avoid hiding it behind unnecessary client-side rendering.
- Review CSS and fonts: Remove blocking styles that are not needed for the first view. Confirm that the chosen font, fallback behavior, and font loading strategy do not hold the main heading or content invisible longer than necessary.
- Reduce JavaScript before first render: Defer nonessential scripts, split large bundles, and avoid running analytics, personalization, or hydration work before the main content is usable.
- Inspect caching and delivery: Confirm that repeat visits can reuse static assets and that immutable, versioned files are served efficiently. Review this as part of your web deployment checklist.
When INP is slow
INP problems usually involve event handlers, rendering work, or long tasks on the main thread. Test the interaction that feels slow: opening a menu, submitting a form, filtering a list, switching tabs, or typing into a search field.
- Find long tasks around the interaction in the Performance panel.
- Break up expensive loops and avoid processing an entire dataset synchronously when only part of it is visible.
- Move nonurgent work out of the interaction’s critical path.
- Reduce the amount of DOM work triggered by each event.
- Use event delegation where it simplifies listener management, but do not treat it as a universal performance fix.
- Check third-party scripts that attach listeners or run immediately after user input.
- Measure production bundles and dependencies, not only the source files. The JavaScript bundle size guide can help connect dependency choices to runtime work.
Use input debouncing for actions such as search suggestions when intermediate keystrokes do not need immediate processing. Do not debounce interactions that require instant feedback without first considering accessibility and user expectations.
When CLS is high
CLS is commonly caused by content that appears after the initial layout or by dimensions that change after rendering. Capture a recording and note exactly which element moved.
- Set explicit
widthandheightattributes or an appropriateaspect-ratiofor images, video, embeds, and reserved media slots. - Reserve space for advertisements, consent interfaces, recommendations, and asynchronously loaded components.
- Do not insert banners above existing content after the page has rendered unless the layout has already reserved room.
- Check font swaps, especially where fallback and final fonts have different metrics. A fallback strategy can reduce visible movement.
- Inspect client-side rendering and hydration for markup that changes after the server response.
- Animate properties such as
transformwhere appropriate instead of repeatedly changing layout-affecting dimensions.
When all three metrics are weak
Look for a shared cause before optimizing each metric independently. A large JavaScript application can delay LCP, create long interaction tasks that hurt INP, and cause CLS when components render late. A slow server can delay the document and every resource discovered from it. Start with the critical path: document response, critical CSS, LCP resource, JavaScript execution, and layout reservations.
What to double-check
Before changing code, record the page, viewport, device emulation, connection profile, browser, release identifier, and test conditions. Compare the same route before and after the change. A performance audit without this context can lead to false conclusions.
In browser developer tools, use the Network panel to check request order, response sizes, cache behavior, redirects, and priority. Use the Performance panel to locate long tasks, layout shifts, scripting time, and the LCP event. Inspect the rendered page, not just the source: a framework may defer, replace, or hydrate content after the initial response.
Also check the deployment layer. A build configuration can accidentally ship source maps or development code, disable compression, remove cache headers, or include a larger JavaScript entry point than expected. If package changes caused the regression, compare lockfiles and generated bundles. For formatting or inspecting structured build output, a JSON formatter and validator can make machine-generated configuration easier to inspect.
Finally, verify that the fix works on the actual route and template where users experience the problem. Improving a product page does not necessarily improve the checkout route, and a fast homepage does not prove that an authenticated dashboard is responsive.
Common mistakes
- Optimizing a score instead of a cause: Treat the audit as evidence. Find the element, request, task, or shift behind the result.
- Confusing lab and field data: A controlled test can reproduce a local problem, while field data can expose device, network, or interaction patterns that a lab run misses.
- Lazy-loading the LCP element: Deferring below-the-fold media is useful; delaying the main visible content can make loading slower.
- Removing all third-party code indiscriminately: Inventory each script, identify its business purpose, and measure its cost before replacing or deferring it.
- Chasing bundle size alone: Download bytes matter, but parsing, compiling, executing, and rendering the code can be just as important for INP.
- Testing only a warm cache: Compare cold and repeat visits where relevant, and document which scenario the product actually needs to support.
- Making several changes at once: Bundling unrelated optimizations makes it difficult to know what helped or introduced a regression.
When to revisit
Re-run this checklist before seasonal planning cycles, after a major template or framework change, and whenever deployment tooling changes. It should also be part of release review for changes to images, fonts, analytics, consent managers, personalization, navigation, search, checkout, or any shared JavaScript component.
Keep a small performance record containing the tested URLs, field-data view, lab setup, metric values, suspected cause, change made, and result. Set a regression check for representative routes rather than relying on one homepage audit. When a result worsens, compare the last known good release with the first affected release and inspect the generated assets and network waterfall.
Before acting, use this short sequence:
- Confirm which metric is failing and whether the evidence is field or lab data.
- Identify the element, interaction, task, request, or layout shift responsible.
- Form one hypothesis and choose the smallest safe change.
- Test on the affected route under documented conditions.
- Review both performance and functionality, then record the result.
Core Web Vitals work is not a one-time cleanup. Treat it as a JavaScript workflow that travels with your releases, dependencies, deployment configuration, and templates.