AI Global Academy Join the waitlist

Courses / Frontend: the website

Lesson 3.9 · 55 minSpeed and search basics

Duration~55 min in the lesson + ~30 min homework
PrerequisitesCheckpoint lesson-3.8.
Checkpointlesson-3.9

What you will have

You have measured the live site with Lighthouse in Chrome DevTools, had Claude check the page in its browser and fix the top issues, and measured again, with both reports saved in docs/lighthouse/. The site has a sitemap and a robots file on the live domain, and structured data describing the business.

Video

The video for this lesson is not recorded yet.

Prompts used in this lesson

Part 4 — Measure, fix, measure again

Prompt to Claude
Purpose: record a baseline of the live site's speed before changing anything.

Context: the live site is https://[your-domain]. I ran Lighthouse in Chrome
DevTools (Navigation, Mobile, all categories) three times, kept the middle
run and saved it as docs/lighthouse/before.report.html and
docs/lighthouse/before.report.json.

Done when you give me a table from the JSON: the Lighthouse version, the date
of the run and the device it emulated; the performance, accessibility, best
practices and SEO scores; LCP, CLS and Total Blocking Time; which element is
the LCP element; and the top five opportunities, each explained in one plain
sentence.

Constraints: read only; change no code and do not run Lighthouse yourself. If
the files are missing or the device is not mobile, stop and tell me.
Prompt to Claude
Purpose: check the live home page in a real browser, to sit next to the
Lighthouse baseline.

Context: the live site is https://[your-domain]. Use the Playwright browser
tools.

Done when docs/lighthouse/browser-before.md exists with the date and these
findings, taken from the live page with the browser window at 375 by 812:
- the page title and meta description;
- every image: the file it loaded (currentSrc), the width it is shown at,
  whether it loads lazily, and its alt text; flag images whose requested
  width is far larger than they are shown;
- the LCP element and time from a PerformanceObserver for
  largest-contentful-paint with buffered: true, plus responseStart and
  loadEventEnd from the navigation timing entry;
- whether /sitemap.xml and /robots.txt answer with status 200;
and a screenshot saved as docs/lighthouse/home-375-before.png.

Constraints: change no code. Say in the file that the timings come from my
computer without throttling, so they are not Lighthouse numbers.
Prompt to Claude
Purpose: fix the biggest speed problems in the baseline without changing how
the site looks or behaves.

Context: baseline in docs/lighthouse/before.report.json and
docs/lighthouse/browser-before.md. Read the image and font guides in
node_modules/next/dist/docs first.

Done when the top opportunities are fixed, and you have checked and reported
on each of these:
1. the hero image is requested at a size suited to the viewport and is the
   only eagerly loaded image; other images lazy-load; source files are no
   larger than needed;
2. only the font families and weights the design uses are loaded;
3. no unused libraries or imports remain, icons are imported individually,
   and only components that need interactivity run in the browser.

Constraints: no visual changes, no new libraries, no removed features. Do not
chase 100, and do not run Lighthouse; I measure again after the deployment.
Tell me what you left and why. Before reporting: build and lint; start the
production server and, with the Playwright browser, check the image sizes
again and compare screenshots at 375px, 768px and 1280px with the live site;
list each change and the baseline item it addresses. Then commit and push.
Prompt to Claude
Purpose: measure the result of the speed fixes.

Context: the fixes are deployed. Baseline: docs/lighthouse/before.report.*
and docs/lighthouse/browser-before.md. I ran Lighthouse again the same way
and saved docs/lighthouse/after.report.html and after.report.json.

Done when:
- docs/lighthouse/browser-after.md and home-375-after.png exist, made the
  same way as the "before" browser check;
- docs/lighthouse/summary.md has a before/after table of the four category
  scores, LCP, CLS and Total Blocking Time, with the date, the URL, the
  Lighthouse version of each run, and one line on what remains unfixed and
  why.

Constraints: first confirm that the latest commit is the one deployed. If the
two runs used different Lighthouse versions or devices, say so at the top of
summary.md. /sitemap.xml and /robots.txt are still missing at this point;
note that, but do not fix it.

Part 5 — Search basics

Prompt to Claude
Purpose: make the site easy for search engines to read.

Context: siteUrl is in content/site.ts. Index: /, /privacy, /terms. Do not
index: /thank-you, /styleguide. Later sections add /admin and /api, which
crawlers should not crawl. Business facts are in content/site.ts and
docs/brief.md. Read the sitemap, robots and JSON-LD pages in
node_modules/next/dist/docs first.

Done when:
- app/sitemap.ts generates /sitemap.xml with only the three public pages, as
  absolute addresses built from siteUrl;
- app/robots.ts generates /robots.txt that allows crawling in general,
  disallows /admin and /api, and points to the sitemap;
- the home page includes JSON-LD of the fitting schema.org local-business
  type with only: name, description, url, telephone, email, address or area
  served, and opening hours if docs/brief.md states them;
- every indexable page has a canonical address.

Constraints: no ratings, reviews, prices or awards unless they are in
docs/content.md and visible on the page. Escape the JSON as the Next.js guide
describes. Before reporting: build; start the production server; with the
Playwright browser, open /sitemap.xml, /robots.txt and the home page, and
show me the full contents of both files and the JSON-LD as rendered in the
home page's HTML, plus each indexable page's title, description and
canonical address.

Do along

Work on your own project and pause the video where told.

  1. Start from lesson-3.8, deployed. In your own terminal in VS Code (the project folder), run claude mcp list and check that playwright is connected.
  2. Pause after Part 3. Open your live domain in an Incognito window. Open DevTools, then the Lighthouse panel. Choose Navigation and Mobile, keep all categories, and click Analyze page load. Find the category scores, LCP, CLS and Total Blocking Time.
  3. Pause after Part 4. Run Lighthouse three times and keep the middle run. Save it as HTML and as JSON into docs/lighthouse/, named before.report.html and before.report.json.
  4. Run the baseline prompt and the browser check prompt with your domain. Read the top five opportunities and browser-before.md.
  5. Run the fix prompt. Check the page at three widths before accepting that nothing changed visually.
  6. After the deployment, run Lighthouse again the same way and save after.report.html and after.report.json. Run the "after" prompt and read docs/lighthouse/summary.md.
  7. Pause after Part 5. Run the search prompt. Read the sitemap, robots file and structured data in full; remove any fact that is not true.
  8. After Part 6, push. Open /sitemap.xml and /robots.txt on your live domain. Run Lighthouse with only SEO ticked and add the score to summary.md.
  9. Save the checkpoint with the commands under "Recap and next".

Check your work

  1. Open docs/lighthouse/. Expected: before.report.html, after.report.html, their JSON files, browser-before.md, browser-after.md, the two screenshots and summary.md; both HTML reports open in a browser.
  2. Read summary.md. Expected: the Lighthouse version of each run, and in the "after" column LCP 2.5 s or less and CLS 0.1 or less, with Total Blocking Time in Lighthouse's good range, or a written reason for anything that is not.
  3. Open browser-after.md. Expected: no image requested at a width far larger than it is shown.
  4. Open https://your-domain/sitemap.xml. Expected: three addresses, all beginning with your https:// domain.
  5. Open https://your-domain/robots.txt. Expected: a general allow, disallow lines for /admin and /api, and a sitemap line.
  6. npm run build and npm run lint. Expected: both pass.

Common problems

  • Scores differ between runs → normal variation → run three times, take the middle, and compare before and after under the same conditions, on the same computer.
  • Your scores differ from the video → lab results depend on the computer and its load → compare only your own runs with each other.
  • The saved report is not in the project → Chrome put it in your Downloads folder → move both files into docs/lighthouse/ and rename them as the lesson says.
  • Claude says it has no browser tools → the Playwright MCP server is not connected in this project folder → run claude mcp list; if playwright is missing, add it as in lesson 1.6 and restart Claude Code.
  • Claude's timings look much better than Lighthouse's → expected: its browser runs at your computer's full speed and may reuse cached files → use Lighthouse for the scores and Claude's check for what it saw on the page.
  • Sitemap lists http://localhost:3000 → siteUrl is wrong → correct it in content/site.ts and redeploy.

Homework

About 30 minutes, after the lesson. No later lesson depends on it.

  1. Measure two more pages. Run Lighthouse in DevTools, in an Incognito window, with the same options, on your own /privacy page and on the home page of a business like yours. Deliverable: docs/lighthouse/other-pages.md with the date and, for each page, the four category scores, LCP, CLS and Total Blocking Time, plus one sentence on the biggest difference from your home page. Commit without a tag. Done when: the file has both pages and you did not touch the before and after reports.
  2. Phone on mobile data. With Wi-Fi off, open your domain in a private tab three times and count the seconds until the headline is readable. Deliverable: three timings in your notes, with date and place. Done when: you have three numbers and one line on whether the wait felt acceptable.
  3. Search baseline. Search for your business name, then for your service plus your city. Deliverable: in your notes: the date, whether your site appeared for each search, and the titles of the top three results. Done when: both searches are recorded. Whatever you see today is the baseline to compare against later.

Save your work

git add -A
git commit -m "Lesson 3.9: Lighthouse baseline and fixes, sitemap, robots, structured data"
git tag lesson-3.9
git push
git push --tags