Coding & automation

Fix a slow AI-built website with Agent Skills: measure images, scripts and layout shifts

Find what delays the first screen, make a bounded repair and measure again. Follow our original before/after website, six Lighthouse runs and a checked catalog interaction.

Claude CodeCodex
AI-generated editorial illustration, not an actual product screenshot.
On this page
THE QUICK TAKE
  • An image and a render-blocking download can delay the first screen for different reasons.
  • Use the same measurement conditions and recheck useful behavior after the repair.
  • A lab score and TBT do not establish real-user Core Web Vitals or INP.

Three mobile Lighthouse runs per version measured the combined change. Claude Code interpreted the supplied artifacts; it did not capture a browser trace. Real-user Core Web Vitals and INP were not measured.

Files for this exercise

AIHotple example files and prompts. Try the exercise before substituting real work data.

Start with a visible problem and an evidence file

If an AI-built page feels slow, “optimize everything” is a poor first request. Give the assistant a page, a measurement and a behavior that must remain intact. In this exercise, Cedar Catalog should show its product story promptly and still display the correct fictional catalog count when asked.

The Before version deliberately combines three common mistakes: a 2,329,524-byte PNG for a 900-pixel-wide hero, lazy loading on that first-screen image, and a 3,425,403-byte catalog script loaded synchronously in the document head. The image also has no dimensions reserved in the markup. This is an exaggerated teaching fixture, so its unusually large improvement is not a forecast for your site.

Agent Skills provides a performance-optimization workflow centered on measuring before and after a targeted change. Its separate web-performance-auditor persona also requires sourced metrics and identifies the rendering framework before proposing framework-specific repairs. Here the page is plain HTML and JavaScript; a recommendation to add a React or Next.js component would miss the actual project.

Measured lab LCP falls from 24.14 seconds to 0.90 seconds; field data and INP remain unmeasured.
Editorial diagram summarizing our six Lighthouse navigation runs. These are simulated mobile lab measurements of an intentionally inefficient example. · Open full-size image ↗

1. Open the two versions and check the useful action

Download and extract the practice ZIP. Open a terminal in the extracted root and start performance-lab/server.mjs with Node.js. Keep that terminal running, then open the Before address below in Chrome. The page uses only local files and sends no audience analytics.

Scroll to Show catalog summary and click it. The result should read 50,000 fictional items. Open after.html in the same browser, click the same button and compare the count. We observed the correct count in both versions. The image and the product message are retained; the optimized image has less grain because it is smaller and compressed.

This check matters because the repair moves work rather than eliminating all of it. Before downloads and parses the catalog before the page can render. After fetches catalog.json only on request. Its 3,425,281-byte response still costs time and data when clicked. We verified the successful output, not click-to-result latency or its network-failure branch. For a real count-only feature, a small server summary would often be more appropriate than downloading the full catalog.

Start the original local performance exercise
node performance-lab/server.mjs
# Open http://127.0.0.1:8594/before.html
# Then open http://127.0.0.1:8594/after.html
  1. Open Before and click Show catalog summary

    Check the result: 50,000 fictional items. Do not time a warm repeat as a cold first load.

  2. Open After and repeat the action

    The count should match. The initial page no longer loads the large catalog script.

  3. Keep the server open for measurement

    Use the same local origin, computer and audit settings for both addresses.

2. Capture comparable lab measurements

Use a current Node release supported by your Lighthouse version and an installed Chrome. Our pinned Lighthouse 13.5.0 requires Node 22.19 or newer; we used Node 24.20.0. The command below downloads that public npm package on first use. It does not require a paid API or modify your site.

Run Before, then After, and repeat that pair three times while avoiding other heavy work. Save each report with a different output filename. We used the mobile defaults: a 412 × 823 CSS-pixel emulated viewport, simulated network throttling at 1,638.4 Kbps throughput and a four-times CPU slowdown. The local server uses no transfer compression and sends no-store cache headers. Production compression and CDN caching can change the result. These settings model a constrained load; they do not mean six real phones visited the page.

In Chrome DevTools, an alternative is to open Lighthouse, choose a navigation audit and the mobile performance configuration, then Analyze page load. Check the actual report settings before comparing with our CLI values; different throttling, cache state, versions or hardware can change results. The ZIP contains our six numeric rows, settings and selected unchanged fields from representative run-two reports.

Read Chrome’s official Lighthouse workflows ↗

Capture one pinned Lighthouse report; repeat for both addresses
npx --yes lighthouse@13.5.0 http://127.0.0.1:8594/before.html --only-categories=performance --output=json --output-path=before-1.json --chrome-flags="--headless=new"
# Replace before.html / before-1.json with after.html / after-1.json.
# Repeat the pair as runs 2 and 3, with new output filenames.

3. Give the skill readable evidence

Open Claude Code with your complete Agent Skills clone, as in our installation article. Invoke performance-optimization and supply the page files plus the measurement JSON. A skill file alone does not give the assistant access to Chrome or to your real users.

Our first artifact-review attempt could not read the large, single-line report and catalog files in full. We extracted the relevant original audit fields and resource sizes into a compact JSON file, then repeated the review with those fields and all six measurement rows. This avoided asking the model to guess what an unreadable attachment contained. The downloadable evidence includes that extract and the final response.

The final response identified the static HTML, pointed to the hero’s LCP element snippet, the large synchronous script and the changed image dimensions. It kept field metrics and INP marked as unmeasured. It also warned that the changes were bundled and that moving the catalog to a click needed a functional check. We performed that successful browser check separately; the assistant itself had read access and no browser connection.

Copy and adapt this prompt
/agent-skills:performance-optimization Review performance-lab/before.html and performance-lab/after.html plus performance-summary.json, performance-measurements.json and performance-audit-extract.json. Identify the rendering framework. Rank the image, script and layout issues using the recorded audit fields. Separate measured lab values, source-based explanations and unmeasured field data. Do not invent INP or claim browser actions. Keep useful behavior intact and state the cost moved to the click path.

Load Agent Skills and verify the intended skill is available →

4. Read the improvement without overstating it

The table reports the median of each metric across three runs per version. The median values do not all have to come from the same run. Before LCP ranged from 24,138.98 to 24,147.09 ms; After ranged from 902.40 to 902.84 ms in this local series. Wider variation on your setup is normal.

Lighthouse identified the hero image as the LCP element. The After page requests a 25,462-byte WebP eagerly with fetchpriority="high" and explicit width and height, and it removes the blocking catalog script from initial navigation. The measured transfer includes response overhead; that is why the audit’s bytes are slightly larger than the files on disk.

These changes were measured together. They show that the combined revision improved this lab navigation; they do not establish the separate millisecond benefit of WebP, fetch priority or reserved dimensions. We also did not run a trace attribution study of every shift. The dimension repair is consistent with the observed CLS change, rather than a separately isolated causal experiment.

Metric: median of three mobile runsBeforeAfter
LCP, lab estimate24,144 ms903 ms
FCP, lab estimate17,694 ms632 ms
CLS, lab navigation0.1490
TBT, lab navigation45 ms0 ms
Initial transferred bytes5,757,10427,532
Lighthouse performance score49 / 100100 / 100
INP and real-user field dataNot measuredNot measured

5. Keep the fix useful after the score improves

TBT measures blocking work during a lab load. It is not an INP result. A navigation audit that never clicks Show catalog summary cannot tell you how responsive that later interaction is. A perfect score for this small first screen therefore does not mean the complete application is fast.

For an operating site, check the real-user picture separately. Google’s current Core Web Vitals are LCP, INP and CLS, assessed at the 75th percentile of visits, segmented by device. The good thresholds are LCP within 2.5 seconds, INP at most 200 milliseconds and CLS at most 0.1. Do not attach a “passed Core Web Vitals” claim to this exercise: it has no field sample.

Before releasing a similar repair, check the button, error handling, mobile layout and the visual quality of the smaller image. Retest the important interaction on a constrained connection. Keep an initial-transfer budget and repeatable lab checks, then use appropriate real-user measurement for field outcomes. If your evidence points to slow server responses or a database query instead, investigate that bottleneck before changing the image pipeline.

The corrected fictional page displays 50,000 fictional items after Show catalog summary is clicked.
Actual browser screenshot of the local After fixture after the successful click. It verifies the displayed result, not interaction latency or a real store. · Open full-size image ↗

Check forms and saved data beyond the first screenshot →

Choose a workflow for your next coding problem →

Sources & verification

Original, intentionally inefficient static HTML teaching fixture; not an audit of AIHotple or a customer site. Lighthouse 13.5.0, Headless Chrome 155 and Node 24.20.0 on Windows, 25 October 2026. Three interleaved mobile navigation runs per version used default simulated throttling; each displayed metric is its own median. Agent Skills 0.6.13 in Claude Code 2.1.310, model claude-opus-5-5, reviewed the HTML and editor-extracted Lighthouse fields. The editor made the before/after fixture and captured the measurements separately. No Chrome DevTools MCP, CrUX, RUM, paid API or real-user performance improvement was verified.

  1. Agent Skills · performance optimization
  2. Agent Skills · web performance auditor and metric honesty
  3. Chrome · run Lighthouse and interpret audits
  4. Google · Core Web Vitals and field thresholds
  5. Google · optimize Largest Contentful Paint
  6. Chrome · Total Blocking Time

Sources checked: 2026.10.25

Keep this guide for your next project.Report a correction