Capstone: audit a real site
Audit a whole site. Check its field data, rank the problems by visits and size, find each cause in the lab, prove two fixes with tests, and write the report.
- 01Choose a site and check its field dataPick a site you can change or may test, and check whether CrUX has data for it with the CrUX API, PageSpeed Insights or BigQuery.
- 02Rank the problems, and find each causeRead p75s by page, device and connection, rank problems by visits and by how far past the line, and reproduce each one with the right lab tool.
- 03Prove fixes, and write the reportTest the top fixes on real visitors with a speed number and a business number, each with its interval, and write a report someone acts on.
One site, from the first visit to the final report
Leaf and Kettle has a new site. An agency built it: four pages, a photo slider, a reviews box and a cookie banner. It looks lovely. Four weeks after the launch, the owner asks Ravi two questions. Is the new site fast for our customers? And if not, what do we fix first?
Ravi has done each part of this before, one lesson at a time. Now he does all of it, on one whole site, in order. This is the last lesson of the course. You'll follow Ravi through his audit. Then you'll do the same for a site you choose.
Here is where the audit ends. Ravi tested two fixes on real phone visitors:
// The two fixes the audit tested on phone visitors: a is the page as it was, b has the fixconst tests = [ { fix: "Home photo first", metric: "p75 LCP (ms)", a: 4772, b: 964 }, { fix: "Room for the reviews", metric: "p75 CLS", a: 0.17, b: 0 },];for (const t of tests) { console.log(`${t.fix}: ${t.metric} ${t.a} in a, ${t.b} in b`);}- Line 1 is a comment. A coin put each visitor in a group:
agot the page as it was,bgot the fix. - Line 3 is the home page. LCP is when the biggest thing on the screen appeared, in milliseconds (ms). p75 means three visits in four were at or under that number.
- Line 4 is the Mint tea page. CLS adds up how much the page moved under the visitor's eyes.
- Lines 6 to 8 print one line per test. The first is
Home photo first: p75 LCP (ms) 4772 in a, 964 in b.
Google calls an LCP of 2,500 ms or less good, and a CLS of 0.1 or less. Both fixes took their page from over the line to under it. Why it matters: the owner gets proof from her own customers, not a promise.
Here is the site, and the five steps Ravi took to get there:
At a check-up, the doctor first asks how you've been feeling. Then she runs tests to find the cause. She tries a medicine for two weeks, and checks that it worked. Last, she writes you a letter: what was wrong, what to do, and when to come back.
- In real life: "How have you been feeling?"
- In an audit: Field data: how real visits went
- In real life: The blood test
- In an audit: The lab: a trace you can repeat
- In real life: Two weeks on a new medicine
- In an audit: A test of the fix on real visitors
- In real life: The letter you take home
- In an audit: The report
Start from real visitors. Rank the problems by how many visits they hurt and how badly. Find each cause in the lab. Prove each fix on real visitors. Then write it down so someone acts. Each step uses what the step before it found.
The audit has five steps:
- Step 1: choose a site you can test, and find its field data.
- Step 2: read the field data by page, device and connection, and rank the problems.
- Step 3: make each top problem happen in the lab, and find its cause.
- Step 4: try each fix on the live page, then test it on real visitors.
- Step 5: write the report, with what the fixes are worth.
The relaunched site is published, so you can open it yourself, with DevTools or Lighthouse: Home, Shop, Mint tea, Our story.
How the course recorded it
- The site: the agency's four pages at a made-up address, https://leafandkettle.example. Each outside company had its own address too: consent.example, tags.example, reviews.example, fonts.example, and the agency's CMS, cms.example. The CMS took 2.5 seconds to build its list of slides. The published copy keeps every outside file in a folder called
third-party/, and names the home pagehome.html. - The visitors: 480 visits over four weeks, 336 of them on phones, each in a new Chrome tab. Each visitor's phone speed, delay and download speed were drawn as in lesson 13.1. Once the page had settled, each visitor read it for 2.5 seconds, tapped Accept on the cookie banner, then left.
- The lab: Chrome for Testing 157.0.8103.52 as Asha's phone: 412 by 823 pixels, DevTools' Slow 4G, and a CPU 4× slower. Each version loaded 5 times, taking turns, after one round that wasn't kept.
- The tests: 400 more phone visits, to the home page and the Mint tea page. A coin gave each new visitor a group.
Step 1: choose a site you can test
Two things make a site good for an audit.
First, you can change it. It's your own site, your company's, or a friend's who said yes. An audit ends in fixes. If nobody can make them, the report goes in a drawer. Step 4 also tests fixes on real visitors, and only the owner can agree to that.
Second, it has field data: timings from real visitors' browsers (lesson 3.3). The easiest place to get it is CrUX, Chrome's public report of real visits (lesson 10.1). But CrUX only includes pages and sites with enough visitors. Google's rules call it "sufficiently popular", and keep the number secret: "An exact number is not disclosed".
Ask CrUX about your site
There are three ways to ask. The first is the CrUX API, a web address that answers with JSON. Its docs say: "Using the CrUX API requires a Google Cloud API key provisioned for Chrome UX Report API usage." An API key is a code that says who is asking. It's like a library card: free, but you need one to borrow. You make one on Google Cloud's Credentials page.
curl -s --request POST 'https://chromeuxreport.googleapis.com/v1/records:queryRecord?key=API_KEY' \ --header 'Content-Type: application/json' \ --data '{"origin": "https://your-site.example", "formFactor": "PHONE"}'- Line 1 sends a request to the API. Your key goes where it says
API_KEY. - Line 2 says the request body is JSON.
- Line 3 asks about one origin, a whole site like https://your-site.example, on phones only.
If CrUX has data, the answer holds each metric's p75. If it has none, Google's guide shows the answer you get: an error with the code 404. Here is what to do with each:
// What the CrUX API answered for a small shop's originconst answer = { error: { code: 404, message: "chrome ux report data not found", status: "NOT_FOUND" } }; if (answer.error?.code === 404) { console.log("No CrUX data for this origin. Measure your own visitors.");} else { const lcp = answer.record.metrics.largest_contentful_paint.percentiles.p75; console.log(`CrUX p75 LCP on phones: ${lcp} ms`);}- Line 2 is the answer for a small shop: 404, "chrome ux report data not found".
- Lines 4 and 5 check for that 404, and print
No CrUX data for this origin. Measure your own visitors. - Lines 7 and 8 would print the p75 LCP, for a site CrUX knows.
The second way is PageSpeed Insights, at pagespeed.web.dev. Paste an address, and it shows CrUX's field data next to a Lighthouse test. If the page has too few visits, it shows the whole origin instead. Its docs add: "Sometimes the origin may also have insufficient data, in which case PSI will be unable to show any real-user experience data." PageSpeed Insights also has an API, which takes the same key=. Google plans to stop sending CrUX's data through it, and points to the CrUX API instead.
The third way is CrUX on BigQuery, a database you query with SQL. It needs a Google Cloud account, and is free up to a monthly limit. It's updated once a month and holds whole origins, not single pages. It's the place for trends over many months, as in lesson 10.1.
When CrUX has nothing: measure your own visitors
Leaf and Kettle is a small shop, so CrUX has no data for it. Ravi doesn't need it. In lesson 45.2 he built his own RUM, real-user monitoring: a script on each page that sends home one beacon, a small report, per visit. That's where this audit's field data comes from. For this lesson, the course ran Ravi's pipeline on the relaunched site with simulated visitors. It was real Chrome, on the real pages. Each visitor's phone and network were drawn as lesson 13.1 drew them.
Start your own audit here. Type your site, and tick each step as you go:
I can change this site, or its owner agreed to the audit.
Step 2: read the field, page by page
Ravi's rum.js already sends LCP, INP and CLS from each visit, with the page, the device and the connection. INP is how long the page took to answer the slowest tap. The new site needs two small changes:
// rum.js: one more field in the beacon group: document.documentElement.dataset.group ?? null, // collector.mjs: the site's pages, the test groups, and the group in each stored lineconst PAGES = ["/", "/shop.html", "/mint-tea.html", "/story.html"];const GROUPS = ["a", "b"]; group: GROUPS.includes(body.group) ? body.group : null,- Line 2 adds the page's test group to each beacon. Step 4 needs it. Until then, it's
null. - Line 5 lists the new site's four pages, so the collector keeps them.
- Lines 6 and 7 let the collector keep the group, if it's a or b.
Every page, on every device
Four weeks later, Ravi has 480 beacons. He splits them by page and device, and finds each p75, as lesson 12.5 did. Each row is one page on one kind of device:
| Page and device | Visits | p75 LCP | p75 INP | p75 CLS |
|---|---|---|---|---|
| Home, phones | 154 | 4,588 ms | 232 ms | 0.00 |
| Home, computers | 62 | 144 ms | 72 ms | 0.00 |
| Shop, phones | 52 | 716 ms | 248 ms | 0.00 |
| Shop, computers | 20 | 164 ms | 64 ms | 0.00 |
| Mint tea, phones | 89 | 632 ms | 232 ms | 0.17 |
| Mint tea, computers | 43 | 196 ms | 64 ms | 0.05 |
| Our story, phones | 41 | 1,164 ms | 128 ms | 0.00 |
| Our story, computers | 19 | 296 ms | 56 ms | 0.00 |
Read down each column. Every computer row is under every line. The problems are all on phones. That fits: phones are slower, and so are their networks. Here are the four phone numbers the audit follows, each against its line:
Three are over their line. Our story's LCP is under it, at 1,164 ms. Why it matters: Ravi now knows where to look, and where not to.
Split by connection
Each beacon also says the visitor's connection, as Chrome guesses it: 4g, 3g and so on. Splitting by it shows whether a problem is the network's or the phone's:
// p75 LCP of the home page on phones, by connection, from Ravi's RUMconst rows = [ { connection: "4g", visits: 124, p75: 4252 }, { connection: "3g", visits: 30, p75: 5336 },];for (const { connection, visits, p75 } of rows) { console.log(`${connection}: ${p75} ms over ${visits} visits`);}- Lines 3 to 4 hold each connection with its visits and its p75 LCP.
- The loop prints one line each. The first is
4g: 4252 ms over 124 visits.
Even the 4g phones are over the line, and the slower ones are further over. So a faster network alone won't fix the home page: something on the page makes the photo wait. Why it matters: a problem everybody feels needs a fix in the page, not a wish for better phones.
Rank by visits and size
A busy clinic has one doctor. The nurse at the front desk decides who goes first. A whole football team with sprained ankles might come before one person with a cut finger. She looks at how many, and how bad, together.
- In real life: How many people have the same problem
- In ranking problems: The share of visits in the segment
- In real life: How badly each one is hurt
- In ranking problems: How far the p75 is past its line
- In real life: Who the doctor sees first
- In ranking problems: The problem with the highest priority
Lesson 40.1 gave Ravi the sum: the share of all visits in the segment, times how far its p75 is past the good line. Here are the four problems:
// Each problem on phones: share of all visits (%), its p75, and its good lineconst problems = [ { name: "Home photo", share: 32.1, p75: 4588, line: 2500 }, { name: "Reviews box", share: 18.5, p75: 0.17, line: 0.1 }, { name: "Accept tap", share: 70, p75: 232, line: 200 }, { name: "Story font", share: 8.5, p75: 1164, line: 2500 },]; for (const p of problems) { const over = Math.max(0, Math.round((p.p75 / p.line - 1) * 100)); console.log(`${p.name}: ${over}% over, priority ${Math.round((p.share * over) / 10) / 10}`);}- Lines 3 to 6 hold each problem: its share of all visits in percent, its p75 on phones, and its good line.
- Line 10 works out how far past the line, in percent. Under the line counts as 0.
- Line 11 multiplies the two, and prints. The lines are
Home photo: 84% over, priority 27,Reviews box: 70% over, priority 13,Accept tap: 16% over, priority 11.2andStory font: 0% over, priority 0.
The home photo comes first, then the reviews box. The Accept tap reaches the most visits, 70% of them, but it's only 16% past its line. Is multiplying the right way to weigh them? Try other weights:
- Home photo: LCP 4,588 ms, 32.1% of visits, 84% pastscore 51.9
- Reviews box: CLS 0.17, 18.5% of visits, 70% pastscore 36
- Accept tap: INP 232 ms, 70% of visits, 16% pastscore 33.5
- Story font: LCP 1,164 ms, 8.5% of visits, 0% pastscore 0
Each score is the share of visits to the power 0.5, times how far past the line to the power 0.5. "Both equally" puts the problems in the same order as lesson 40.1's priority. A problem under its line scores 0.
Counting only visits puts the Accept tap first: it's on every page. Counting only distance gives the same order as multiplying. Multiplying both is the middle way, and Ravi keeps it. Why it matters: write down the rule you ranked with, so the owner can question it.
Step 3: find each cause in the lab
The field says where and who. It can't say why. For that, Ravi makes each problem happen again in the lab: Chrome on his own computer, set up like the phones that hurt. As in lesson 40.1, that's DevTools' Slow 4G and a CPU 4× slower. He loads each page 5 times and keeps the middle load.
You tell the mechanic your car rattles on the motorway. She can't fix a rattle she can't hear. So she drives the same road, at the same speed, with a tool that listens to each part of the engine. Then she knows which part to fix.
- In real life: "It rattles on the motorway"
- In the lab: The field: home LCP is slow on phones
- In real life: Driving the same road at the same speed
- In the lab: The lab, set up like those phones
- In real life: The tool that listens to each part
- In the lab: A trace, Long Animation Frames, shift attribution
Each problem needs its own tool. Here they are, one by one.
The home photo: a trace, and LCP's four parts
Ravi records the home page in DevTools' Performance panel. DevTools splits the LCP into four parts (lesson 17.2): waiting for the page's first byte, waiting before the photo starts, the photo's download, and drawing it.
// The home photo's LCP on Asha's phone in the lab, in four parts, from DevTools' trace engine (ms)const parts = { ttfb: 564, loadDelay: 3183, loadDuration: 2180, renderDelay: 10 };const lcp = Object.values(parts).reduce((sum, part) => sum + part, 0); for (const [part, time] of Object.entries(parts)) { console.log(`${part}: ${time} ms, ${Math.round((time / lcp) * 100)}%`);}- Line 2 holds the four parts from DevTools' trace engine, in ms.
- Line 3 adds them up: the LCP.
- The loop prints each part and its share. They are
ttfb: 564 ms, 9%,loadDelay: 3183 ms, 54%,loadDuration: 2180 ms, 37%andrenderDelay: 10 ms, 0%.
The photo didn't even start for 3,183 ms. The trace shows why. The photo isn't in the HTML. slider.js adds it, and the browser runs that script only after the page is read. Then the script asks the agency's CMS for slides.json, and the CMS takes 2.5 seconds to answer. Only then do the photos start. All three come at once, at full size, and share the line. That's why the download takes 2,180 ms too. You can see the wait in real frames:
Why it matters: the fix isn't a smaller photo first. It's letting the browser find the photo in the HTML (lesson 17.3).
The Accept tap: Long Animation Frames
The slow tap is Accept, on the cookie banner. It's the first tap most new visitors make. To see what ran during it, Ravi watches Long Animation Frames (lesson 11.5): frames that took over 50 ms, each with the scripts that ran in it.
// The Accept tap's long animation frame on the Shop page, from a PerformanceObserver (ms)const frame = { duration: 248.7, scripts: [{ invoker: "BUTTON#accept.onclick", sourceURL: "https://consent.example/cmp.js", duration: 206.3 }],};const [script] = frame.scripts;console.log(`${script.invoker} ran ${script.sourceURL}`);console.log(`Its script took ${script.duration} ms of a ${frame.duration} ms frame`);- Lines 2 to 5 are the frame: how long it took, and the script that ran in it.
- Line 4 names the script by its invoker, what the browser called. Here, a click listener on the Accept button.
- Lines 7 and 8 print
BUTTON#accept.onclick ran https://consent.example/cmp.jsandIts script took 206.3 ms of a 248.7 ms frame.
The frame names the consent company's script, because its click listener is where the work started. But the trace's call tree shows where the time went: 161 ms in a function called pack, in tags.example/tags.js. The agency's consent-setup.js tells the banner to start the tags. So the tags script starts its session recorder inside the tap, and the page can't paint until it's done. Why it matters: the fix is in the agency's own file, not in either company's script.
The reviews box: layout shift attribution
Each layout shift tells you which elements moved, where they were, and where they went. Ravi reads them on the Mint tea page (lesson 30.4):
// The Mint tea page's layout shift on Asha's phone: two of the elements it moved (y in CSS pixels)const shift = { value: 0.171, sources: [ { node: "p.price", fromY: 174, toY: 406 }, { node: "img.photo", fromY: 333, toY: 565 }, ],};for (const { node, fromY, toY } of shift.sources) { console.log(`${node} moved down ${toY - fromY} px`);}- Line 3 is the shift's score.
- Lines 5 and 6 are two moved elements, with their top edge before and after, in CSS pixels.
- The loop prints
p.price moved down 232 pxandimg.photo moved down 232 px.
Everything moved by the same 232 px. That's the reviews box, 220 px tall, and the space around it. The reviews company's widget.js fetches the reviews, then puts the box above the price, a second after the page loads. On computers, the box sits at the end of a column, so little moves. Why it matters: Asha may tap Add to cart just as it moves.
Our story: the font, and only on slow connections
Our story's LCP is text, so it has no file to download. Its parts are just the first byte, 564 ms, and the render delay, 1,501 ms. The text waits for the font company's stylesheet and its font files, because the stylesheet says font-display: block (lesson 20.1). But the field said Our story is under the line on every connection. So Ravi notes the cause, and moves on.
Every page: the third parties view
DevTools' Performance panel groups the work by company in its 3rd parties view (lesson 24.1). On the home page, with the Accept tap:
- The site itself: 308,416 bytes, 21 ms of main-thread work.
- tags.example: 442 bytes, 164 ms of main-thread work.
- consent.example: 477 bytes, 3 ms of main-thread work.
- cms.example: 188 bytes, 0 ms of main-thread work.
tags.example sends only a few hundred bytes, but uses the most main-thread time. Why it matters: a small file can still be the most expensive one.
Here is each problem with its tool, in one place:
| The problem | The tool | What it showed |
|---|---|---|
| The home photo comes late | A trace, and DevTools' LCP breakdown. | Most of the wait came before the photo even started, while the slider read its list. |
| The Accept tap is slow | Long Animation Frames, then the trace's call tree. | The frame names the click listener in the consent script. The call tree shows the time inside the tags script. |
| The reviews box moves the page | Layout shift attribution. | Each moved element, with where it was and where it went. |
| Our story waits for its font | The LCP breakdown, and the field's connection segments. | The text has no file of its own, so its wait is all render delay. The field says it passes on every connection. |
| Every page | DevTools' third parties view. | Which outside company's code used the main thread, and how many bytes each one sent. |
Step 4: prove the top two fixes
The top two problems are the home photo and the reviews box. Each fix is small. For the home page, the first photo goes in the HTML, with fetchpriority="high", and the slider adds the other two once it has loaded. For the Mint tea page, one line of CSS keeps the box's room from the start:
#reviews { display: flow-root; min-height: 244px; }Line 1 gives the empty #reviews box its full height before the widget fills it: 220 px, plus 24 px of margins. display: flow-root keeps those margins inside #reviews, so they count in that height.
Try each fix on the live page first
Before shipping anything, Ravi tries each fix on the live site with DevTools' Local Overrides. In the Network panel, he right-clicks a file and picks Override content. DevTools asks for a folder to save it in. Then, as Google's docs say, "When you reload the page, DevTools serves the local, modified file, rather than the network resource." The course did the same with Playwright's request interception.
One catch: a file from your own disk skips the network. So Ravi compares the fixed page with the same page, also served from disk, but unchanged. Here are the middles of 5 loads each:
- Home photo: LCP 5,332 ms unchanged, 1,236 ms with the fix. Straight from the server: 5,940 ms.
- Reviews box: CLS 0.17 unchanged, 0.00 with the fix. Straight from the server: 0.17.
- Accept tap: INP 256 ms unchanged, 48 ms with the fix. Straight from the server: 256 ms.
- Story font: LCP 1,528 ms unchanged, 784 ms with the fix. Straight from the server: 2,068 ms.
The home page alone drops from 5,940 ms to 5,332 ms just by skipping the network. Comparing with that would have flattered the fix. Why it matters: compare like with like, every time.
Then test on real visitors
A café wants to know if its new teapot makes better tea. For a week, a coin at the door decides which pot each customer gets. At the end, the café counts how often each group ordered a second cup. The coin makes the two groups alike, so only the pot differs.
- In real life: The coin at the door
- In an A/B test: The edge's coin: group a or b
- In real life: The old pot and the new pot
- In an A/B test: The page as it was, and with the fix
- In real life: Cups ordered again
- In an A/B test: The business number: clicks, or teas added
- In real life: "Somewhere between 5 and 15 more"
- In an A/B test: The 90% interval
The lab shows the cause. Only real visitors show what the fix does for them. So Ravi runs two tests, the way lesson 40.3 did. The site's edge gives each new phone visitor a group with a coin, and keeps it in a cookie. Group b gets the fixed files, and every page says its group, for rum.js.
Each test measures two numbers:
- The home page: p75 LCP, and the share of visitors who click Shop our teas. Simulated visitors don't choose, so the course uses lesson 40.3's model. A visitor clicks with a chance of 50%, minus 6 points for each second of LCP, but never under 5%.
- The Mint tea page: p75 CLS, and the share of taps that added the tea. In the course's model, a visitor looks at the loaded page for a while, half of them for under 1.5 seconds. Then they tap where Add to cart was 400 ms before. If the page moved in between, the tap lands on the reviews box instead.
// The home photo test: phone visitors split by a coin, 240 in allconst field = { a: 4772, b: 964, low: -4036, high: -3472 };const business = { a: 25.4, b: 50.9, low: 16.2, high: 36.5 }; console.log(`p75 LCP (ms): ${field.a} in a, ${field.b} in b. 90% interval of b - a: ${field.low} to ${field.high}`);console.log(`Clicked Shop our teas: ${business.a}% in a, ${business.b}% in b. 90% interval: ${business.low} to ${business.high} points`);- Line 2 is each group's p75 LCP, and the 90% interval of the change, b minus a, from 500 resamples (lesson 13.2).
- Line 3 is each group's share who clicked, in percent, and the interval of the gap, in points.
- Line 5 prints
p75 LCP (ms): 4772 in a, 964 in b. 90% interval of b - a: -4036 to -3472 - Line 6 prints
Clicked Shop our teas: 25.4% in a, 50.9% in b. 90% interval: 16.2 to 36.5 points
// The reviews room test: phone visitors split by a coin, 160 in allconst field = { a: 0.17, b: 0, low: -0.17, high: -0.17 };const business = { a: 81.1, b: 100, low: 10.8, high: 25.7 }; console.log(`p75 CLS: ${field.a} in a, ${field.b} in b. 90% interval of b - a: ${field.low} to ${field.high}`);console.log(`Tap added the tea: ${business.a}% in a, ${business.b}% in b. 90% interval: ${business.low} to ${business.high} points`);- The lines work the same way, with CLS and the taps that added the tea.
- Line 5 prints
p75 CLS: 0.17 in a, 0 in b. 90% interval of b - a: -0.17 to -0.17 - Line 6 prints
Tap added the tea: 81.1% in a, 100% in b. 90% interval: 10.8 to 25.7 points
Every interval stays on the good side of no change. So both fixes helped real phone visitors, in speed and in what they did. A 90% interval is the range where the true change most likely is. It misses one time in ten. Did the coin split fairly? 130 and 110 visitors on the home page, 74 and 86 on the Mint tea page. The check from lesson 40.3 finds nothing odd in either. Now watch the intervals as the visits come in:
240 visits- p75 LCP: 4,772 ms in a, 964 ms in bb − a: -4,036 ms to -3,472 ms
- clicked Shop our teas: 25.4% in a, 50.9% in b16.2 to 36.5 points
160 visits- p75 CLS: 0.17 in a, 0.00 in bb − a: -0.17 to -0.17
- taps that added the tea: 81.1% in a, 100.0% in b10.8 to 25.7 points
Each range is a 90% interval from 500 resamples of the visits counted so far. A business range that reaches 0 can't yet tell a helpful fix from no change.
Early on, the ranges are wide. After a quarter of the home test's visits, its clicks ran from 17.2 to 54.5 points. With all of them, from 16.2 to 36.5. Why it matters: a test that stops early can promise far too much. Decide when it ends before it starts (lesson 40.3).
Step 5: write the report
The owner asked two questions. The report answers them first, in lesson 40.2's order: the summary, the findings, the actions, how we'll know it worked, and how we measured. It also says what the fixes are worth, the way lesson 41.1 priced one.
A good builder's quote fits on one page. It says what's wrong, what they'll do, when, what it costs, and what it saves you. The last line is where you sign. You can say yes in a minute.
- In real life: "Your roof leaks over the kitchen"
- In a report: The findings: who it hurts, and why
- In real life: "Two new tiles, Tuesday, £160"
- In a report: The actions: who, when, and the hours
- In real life: "Saves you a ruined ceiling"
- In a report: What the fixes are worth
- In real life: "Sign here"
- In a report: The decision the owner makes
Here is the value of each tested fix. The visits are a month of phone visits to each page, from the field data. One shop visit in ten ends in an order, as in lesson 41.1, and so do 3 carts in ten. An average order is £18.
// Each tested fix, priced for a month: the low and high ends of its test's 90% intervalconst orderValue = 18; // the average order, in poundsconst fixes = [ { name: "Home photo first", visits: 154, low: 0.162, high: 0.365, orderShare: 0.1 }, { name: "Room for the reviews", visits: 89, low: 0.108, high: 0.257, orderShare: 0.3 },];for (const f of fixes) { const price = (gain) => Math.round(f.visits * gain * f.orderShare * orderValue); console.log(`${f.name}: £${price(f.low)} to £${price(f.high)} a month`);}- Line 2 is the average order, in pounds.
- Lines 4 and 5 hold each fix: its page's phone visits, the low and high ends of its test's interval, and the orders per gain.
- Line 8 multiplies them, and line 9 prints
Home photo first: £45 to £101 a monthandRoom for the reviews: £52 to £124 a month.
Together, about £97 to £225 a month, for 4 hours of work, £160 at £40 an hour. It's a small shop, so these are small sums. They come every month, though, and the low end is the one to promise.
Here is the top of Ravi's report. The whole report is published: report.md.
# Speed audit: the relaunched Leaf and Kettle site This report covers how fast our four pages are for real visitors, on phones and computers, in the four weeks after the relaunch. It is for the owner and for the agency. ## Summary Phone visitors meet two big problems. The home photo comes late (p75 LCP 4,588 ms; good is 2,500 ms), and the reviews box pushes Add to cart down (p75 CLS 0.17; good is 0.10).We tested a fix for each on real phone visitors, split by a coin. Both worked:- Home photo first: LCP 4,772 ms to 964 ms at p75 (90% interval of the change: -4,036 ms to -3,472 ms). 25.4% clicked Shop our teas before, 50.9% with the fix.- Room for the reviews: CLS 0.17 to 0.00 at p75 (90% interval of the change: -0.17 to -0.17). 81.1% of taps added the tea before, 100.0% with the fix.Do: ship both fixes (4 hours of work, £160). Together they are worth about £97 to £225 of orders a month.We need: a yes to ship both this week, and one hour of the agency's time for the Accept tap.- Line 1 is the title. Line 3 says what the report covers, and who it's for.
- Line 7 says what's wrong, with one number each.
- Lines 8 to 10 give the proof: each test's result, with its interval.
- Line 11 says what to do, what it costs, and what it's worth.
- Line 12 is the decision the owner makes.
The rest of the report has one finding per problem, and the actions, ranked. The Accept tap gets an action too: its fix is the agency's small change to consent-setup.js, lesson 27.2's yieldNow() before the tags start. In the lab, it took the tap from 256 ms to 48 ms. Our story's font goes under "Not now", with its reason. Why it matters: a report that names who, when and what it's worth gets a yes.
// consent-setup.js: let the tap paint first, then start the tags.function yieldNow() { if (globalThis.scheduler?.yield) return scheduler.yield(); return new Promise((resolve) => setTimeout(resolve, 0));} Consent.onAccept(async () => { await yieldNow(); Tags.start();}); - Lines 2 to 5 are
yieldNow():scheduler.yield()where the browser has it, and a timer where it doesn't. - Line 7 hands the banner a function to run on Accept, as before.
- Line 8 waits, so the browser can paint the tap first.
- Line 9 starts the tags afterwards, in a task of their own.
Which step answers this question?
Each question below comes up in an audit, before the report. Sort it into the step that answers it.
- Does CrUX have data for our origin?
- May we test this site at all?
- Which page and device hurt the most visits?
- Is the problem only on slow connections?
- Why does the photo start so late?
- Which script runs during the slow tap?
- Does the fix help real visitors, and by how much?
- Do more visitors click Shop our teas with the fix?
Drag each question to the step that answers it.
Common mix-ups
- "A site that isn't in CrUX can't be audited." No. CrUX is one source of field data. Your own RUM is another, and it can split by page, device, connection, or anything you send.
- "Fix the worst number first." No. A problem few visits meet can matter less than a smaller one many visits meet. Weigh how many and how bad together, and write down the rule.
- "If the lab shows the fix works, it's proven." No. The lab shows the cause on one setup. A test on real visitors shows what the fix does for them, with an interval.
- "Local Overrides show the fix's real effect." No. An overridden file skips the network. Compare the fixed page with the same page overridden unchanged.
- "The long frame names the script that was slow." No. It names the script the browser called. The time may be in code that script called. The trace's call tree shows where.
- "An interval above 0 means the gain is its middle." No. It means the fix most likely helped. The gain is somewhere in the interval, so promise the low end.
Practice exercises
Answer first, then use the hints.
This time the CrUX API knows the origin. What does the code print?
// What the CrUX API answered for a busier shop's origin
const answer = { record: { metrics: { largest_contentful_paint: { percentiles: { p75: 2900 } } } } };
if (answer.error?.code === 404) {
console.log("No CrUX data for this origin. Measure your own visitors.");
} else {
const lcp = answer.record.metrics.largest_contentful_paint.percentiles.p75;
console.log(`CrUX p75 LCP on phones: ${lcp} ms`);
}CrUX p75 LCP on phones: 2900 ms. There's no error, so the code reads record.metrics.largest_contentful_paint.percentiles.p75.
Which problem has the higher priority, and what is it?
// Two made-up problems: share of all visits (%), p75, and the good line
const problems = [
{ name: "Shop grid", share: 40, p75: 0.12, line: 0.1 },
{ name: "Checkout tap", share: 5, p75: 400, line: 200 },
];
for (const p of problems) {
const over = Math.max(0, Math.round((p.p75 / p.line - 1) * 100));
console.log(`${p.name}: ${over}% over, priority ${Math.round((p.share * over) / 10) / 10}`);
}The shop grid: priority 8, against the checkout tap's 5. The grid is only 20% past its line, but it reaches 40% of visits.
In the ranking playground, press Mostly visits. What score does the home photo get?
40.8. The Accept tap now comes first, with 48.4, because it reaches the most visits.
After a quarter of the visits, what is the low end of the reviews test's interval for taps that added the tea, in points?
4.8 points. Even this early, the whole range is above 0, but it's wide: it runs up to 28.6. More visits narrow it.
On the published Mint tea page, which script file fetches the reviews and adds the box?
widget.js, from the reviews company's folder. It fetches reviews.json, then adds the box to #reviews.
The average order is now £24. What is the high end of the reviews fix's value, in pounds a month?
// Each tested fix, priced for a month: the low and high ends of its test's 90% interval
const orderValue = 24; // the average order, in pounds
const fixes = [
{ name: "Room for the reviews", visits: 89, low: 0.108, high: 0.257, orderShare: 0.3 },
];
for (const f of fixes) {
const price = (gain) => Math.round(f.visits * gain * f.orderShare * orderValue);
console.log(`${f.name}: £${price(f.low)} to £${price(f.high)} a month`);
}The high end grows by a third, with the order value. The sum is the same; only one number changed.
Check your understanding
For each question, ask which step of the audit it belongs to.
Question 1 of 7You ask the CrUX API about a small shop's origin, and it answers 404 with "chrome ux report data not found". What does that tell you?
Choose an answer to see the explanation.
Question 2 of 7What does the first line of this priority code print?
Read the code, then predict// Two made-up problems: share of all visits (%), p75, and the good line const problems = [ { name: "Search box", share: 60, p75: 300, line: 200 }, { name: "Cart", share: 4, p75: 0.3, line: 0.1 }, ]; for (const p of problems) { const over = Math.max(0, Math.round((p.p75 / p.line - 1) * 100)); console.log(`${p.name}: ${over}% over, priority ${Math.round((p.share * over) / 10) / 10}`); }Choose an answer to see the explanation.
Question 3 of 7DevTools splits a photo's LCP into four parts, and the second part, load delay, is the biggest. What does that mean?
Choose an answer to see the explanation.
Question 4 of 7A long animation frame names the consent script's click listener, but the trace shows the time inside the tags script. Why?
Choose an answer to see the explanation.
Question 5 of 7Why does the lab compare a fix with the same page through the same interception, not with the page as the server sends it?
Choose an answer to see the explanation.
Question 6 of 7A test says the fix adds 15 clicks per 100 visits, with a 90% interval from 6 to 24. What can the report say?
Choose an answer to see the explanation.
Question 7 of 7Where in the audit report does the answer to the owner's question go?
Choose an answer to see the explanation.
Key takeaways
- Choose a site you can change, and find its field data: CrUX if it has enough visitors, your own RUM either way.
- Split the field by page, device and connection. Rank problems by share of visits times distance past the line.
- Reproduce each top problem in the lab with the right tool: a trace, Long Animation Frames, shift attribution, the third parties view.
- Try fixes with Local Overrides, like with like. Then test the top ones on real visitors, with a speed and a business number.
- Write the report answer first, with intervals, owners, days and what the fixes are worth.
Remember the one-liner.
Start from real visitors, rank by how many and how bad, find the cause in the lab, prove the fix on real visitors, and write it so someone acts.
Sources
The facts on this page come from these docs, standards and source files:
- CrUX API, Chrome for Developers.
- Using the CrUX API, Chrome for Developers.
- CrUX methodology: eligibility, Chrome for Developers.
- About PageSpeed Insights, Google for Developers.
- Get started with the PageSpeed Insights API, Google for Developers.
- CrUX on BigQuery, Chrome for Developers.
- Web Vitals: the thresholds, web.dev.
- Optimize LCP: the four subparts, web.dev.
- Long Animation Frames API, Chrome for Developers.
- Layout Instability API, W3C.
- layout_shift_tracker.cc, lines 708 to 789: shifts soon after an input are left out, Chromium source.
- Third parties insight, Chrome for Developers.
- Override web content and HTTP response headers locally, Chrome for Developers.
- web-vitals, the library rum.js uses, Google Chrome on GitHub.
The reader's files are published too: rum.js, collector.mjs, the fixes in fixes/, and the home page's trace, home-trace.json.gz, for DevTools' Performance panel.
That's the end of the web performance course. You started with what speed means to a visitor, then learned to measure it, in the lab and in the field. You fixed loading, taps and shifts, then followed the browser, the network and the metrics all the way down. Now you can audit a whole site and prove what you changed.
Coming next: what you build. This is the last lesson of the web performance course. The web performance learning path lists every lesson, to review any step. Lesson 44.2's Staying current shows how to follow what changes next. Then pick your site, and start step 1.