debug-optimize-lcp

Guides debugging and optimising Largest Contentful Paint (LCP) using Chrome DevTools MCP tools. Use when the user asks about LCP performance, slow page loads, Core Web Vitals optimisation, or wants to understand why their page's main content takes too long to appear.

How to use

Requires the chrome-devtools-mcp server to be running. Record a performance trace with reload, analyse the LCP breakdown insights, identify the LCP element, check the network waterfall, and apply the prioritised optimisation strategies targeting the bottleneck subpart.

System prompt

Debug and Optimise LCP

Guides debugging and optimising Largest Contentful Paint (LCP) using Chrome DevTools MCP tools.

What is LCP and why it matters

Largest Contentful Paint (LCP) measures how quickly a page's main content becomes visible.

  • Good: 2.5 seconds or less
  • Needs improvement: 2.5–4.0 seconds
  • Poor: greater than 4.0 seconds

LCP is a Core Web Vital that directly affects user experience and search ranking. On 73% of mobile pages, the LCP element is an image.

LCP Subparts Breakdown

Subpart Ideal % of LCP What it measures
Time to First Byte (TTFB) ~40% Navigation start → first byte of HTML received
Resource load delay <10% TTFB → browser starts loading the LCP resource
Resource load duration ~40% Time to download the LCP resource
Element render delay <10% LCP resource downloaded → LCP element rendered

The "delay" subparts should be as close to zero as possible.

Debugging Workflow

Step 1: Record a Performance Trace

  1. navigate_page to the target URL.
  2. performance_start_trace with reload: true and autoStop: true.

Note the insight set IDs from the output — you'll need them in the next step.

Step 2: Analyse LCP Insights

Use performance_analyze_insight to drill into LCP-specific insights:

  • LCPBreakdown — Shows the four LCP subparts with timing for each.
  • DocumentLatency — Server response time issues affecting TTFB.
  • RenderBlocking — Resources blocking the LCP element from rendering.
  • LCPDiscovery — Whether the LCP resource was discoverable early.

Step 3: Identify the LCP Element

Use evaluate_script to reveal the LCP element's tag, resource URL, and raw timing data.

Step 4: Check the Network Waterfall

Use list_network_requests filtered by resourceTypes: ["Image", "Font"]. Then use get_network_request with the LCP resource's request ID for full details.

Key Checks:

  • Start Time: If the LCP resource starts much later than the first resource, there's resource load delay to eliminate.
  • Duration: A large resource load duration suggests the file is too big or the server is slow.

Step 5: Inspect HTML for Common Issues

Use evaluate_script to check for lazy-loaded images in the viewport, missing fetchpriority, and render-blocking scripts.

Optimisation Strategies

1. Eliminate Resource Load Delay (target: <10%)

  • Root Cause: LCP image loaded via JS/CSS, data-src usage, or loading="lazy".
  • Fix: Use standard <img> with src. Never lazy-load the LCP image.
  • Fix: Add <link rel="preload" fetchpriority="high"> if the image isn't discoverable in HTML.
  • Fix: Add fetchpriority="high" to the LCP <img> tag.

2. Eliminate Element Render Delay (target: <10%)

  • Root Cause: Large stylesheets, synchronous scripts in <head>, or main thread blocking.
  • Fix: Inline critical CSS, defer non-critical CSS/JS.
  • Fix: Use Server-Side Rendering (SSR) so the element exists in initial HTML.

3. Reduce Resource Load Duration (target: ~40%)

  • Compress images (WebP/AVIF), use appropriate sizes, serve from CDN.
  • Ensure correct Cache-Control headers.