Chrome DevTools MCP: Diagnose a Slow-Loading Image
Record two page loads on a local demo. Use the traces to see when Chrome requests the hero image and when it paints.
Connect Chrome DevTools MCP
Install Node.js LTS, npm, and the current stable release of Chrome or newer. Model Context Protocol (MCP) gives your coding assistant access to tools that can open pages and record traces in Chrome.
Configure your MCP client to start the server with this command.
npx -y chrome-devtools-mcp@latest
For Codex CLI, register the server with this command, then start a new Codex session.
codex mcp add chrome-devtools -- npx chrome-devtools-mcp@latest
The MCP server launches Chrome when the first browser-dependent tool runs.
Run the localhost demo
Create an empty directory and save these three files in it. The demo uses only Node.js and a local SVG. Its script waits 1,800 ms before setting the image source.
server.mjs
import { createServer } from 'node:http';
import { readFile } from 'node:fs/promises';
const files = new Map([
['/', ['index.html', 'text/html; charset=utf-8']],
['/hero.svg', ['hero.svg', 'image/svg+xml']],
]);
createServer(async (request, response) => {
const file = files.get(request.url);
if (!file) {
response.writeHead(404).end('Page not found');
return;
}
const [name, type] = file;
try {
const body = await readFile(new URL(name, import.meta.url));
response.writeHead(200, { 'Content-Type': type }).end(body);
} catch {
response.writeHead(500).end('Could not read the demo file');
}
}).listen(4173, '127.0.0.1', () => {
console.log('Demo at http://127.0.0.1:4173/');
});
index.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Ridgeline demo</title>
<main style="max-width: 800px; margin: 24px auto">
<h1>Ridgeline demo</h1>
<img id="hero" alt="Blue ridges under a setting sun"
width="480" height="240" style="display: block; max-width: 100%; height: auto">
</main>
<script>
setTimeout(() => {
document.querySelector('#hero').src = '/hero.svg';
}, 1800);
</script>
</html>
hero.svg
<svg xmlns="http://www.w3.org/2000/svg" width="480" height="240" viewBox="0 0 800 400">
<defs>
<linearGradient id="sky" x2="0%" y2="100%">
<stop stop-color="#8eb4e3"/>
<stop offset="100%" stop-color="#fae4cf"/>
</linearGradient>
</defs>
<rect width="800" height="400" fill="url(#sky)"/>
<circle cx="595" cy="112" r="58" fill="#fbbf24"/>
<path d="M0 320 220 100 490 330 660 190 800 315V400H0Z" fill="#526c9e"/>
<path d="M0 360 132 270 305 350 440 240 640 360 800 275V400H0Z" fill="#23395b"/>
<path d="M220 100 171 149 210 134 228 151 236 132 264 139Z" fill="#e8f3ff"/>
<path d="M660 190 623 220 651 213 670 226 694 220Z" fill="#d5e6ff"/>
<path d="M0 385 90 369 155 387 240 375 275 400H0Z" fill="#172946"/>
</svg>
In the demo directory, start the server. Keep this terminal open while recording both traces.
node server.mjs
Paste this prompt into your assistant. The snapshot should contain the heading “Ridgeline demo”.
Open http://127.0.0.1:4173/ with new_page. Use the returned page ID
with take_snapshot. Report the page ID and heading in the snapshot.
Record the baseline trace
Largest Contentful Paint (LCP) marks when the largest visible piece of content finishes rendering. Use the trace to find the final LCP element and see how long Chrome waited before requesting its image.
Use performance_start_trace on the open demo page ID with
reload: true, autoStop: true, and ignoreCache: true.
Save to baseline.json.gz using filePath. If LCPBreakdown is listed,
call performance_analyze_insight with that insight name, the returned
insight set ID, and the same page ID. Report the LCP element's selector
and image URL, the image request start, and LCP in milliseconds from
navigation start. Use the trace evidence for both timings.
Check that the trace identifies img#hero at http://127.0.0.1:4173/hero.svg. The script assigns src after the timer fires, so Chrome discovers the image URL late.
If the insight leaves out the selector or request timing, load baseline.json.gz in the DevTools Performance panel. Select the final LCP marker in the Timings track to inspect its related node. Match its URL to the hero.svg entry in the Network track and read the request start relative to navigation start.
Set the image source in HTML and record again
In index.html, replace <img id="hero" alt= with <img id="hero" src="/hero.svg" alt=. Delete the entire <script> block below </main>. Keep the image, dimensions, and placement the same. Chrome can now discover the URL in the initial HTML.
Record again in the same Chrome version and tab. Keep the viewport and throttling settings fixed and bypass the HTTP cache in both traces.
Record a fresh performance_start_trace on the same demo page ID with
reload: true, autoStop: true, and ignoreCache: true. Save to fixed.json.gz.
Use the new insight set ID with performance_analyze_insight for
LCPBreakdown if listed. Confirm the LCP selector and image URL again.
Compare image request start and LCP in both traces in milliseconds
from navigation start.
Demo observations
One load per version on Linux with Chrome 156.0.8078.47 in headless mode, Chrome DevTools MCP 1.15.0, and Node.js 24.22.1. Both traces used a 1280 × 900 CSS-pixel viewport at device pixel ratio 1, bypassed the HTTP cache, and used no CPU or network throttling. Request start is the trace’s ResourceSendRequest timestamp relative to navigation start.
| Trace | Image request start | LCP |
|---|---|---|
| Delayed source | 1,812.2 ms | 1,835.1 ms |
| Source in HTML | 5.7 ms | 39.9 ms |
Both traces identify img#hero with the same http://127.0.0.1:4173/hero.svg URL. In this demo, putting the source in the HTML moved both the request and LCP earlier.