Lighthouse and Speed Budgets
Measuring speed automatically after every deploy, what the numbers mean, a real before-and-after from this site, and turning measurements into a budget.
Why measure in CI
Speed slips one small change at a time: a new font, a bigger picture, one more script. Nobody notices a 100-millisecond loss. Ten of them make a slow site. The only defence is to measure automatically, after every change, and keep the history.
What Lighthouse measures
Lighthouse, Google's open-source auditing tool, loads a page in a controlled browser and reports scores from 0 to 100 for performance, accessibility, best practices and SEO, plus the timings behind performance:
| Metric | Plain meaning | Good on mobile |
|---|---|---|
| First Contentful Paint (FCP) | When anything appears | under 1.8 s |
| Largest Contentful Paint (LCP) | When the main content appears | under 2.5 s |
| Total Blocking Time (TBT) | How long scripts freeze the page | under 200 ms |
| Cumulative Layout Shift (CLS) | How much the page jumps while loading | under 0.1 |
How this site runs it
A GitHub Actions workflow:
- runs on every push to main, every six hours, and on demand;
- after a push, waits for that commit to be live before measuring, so it measures the new version, not the old;
- tests five representative pages on a simulated mobile phone, three times each, and keeps the median, because single runs are noisy;
- sends the results to the site, where Ravi OS stores them and draws a chart per metric with a dashed line at every deploy.
The workflow runs on GitHub's servers outside India, on simulated slow hardware. The numbers are best for comparing over time, not as the speed a reader in India actually experiences.
A real before and after
Speed tracking started on the same evening as a change that stopped the site's web fonts from blocking the first paint (the fonts were loaded from a stylesheet import, which made the browser wait). In the first runs, mobile performance scores sat in the high 70s to low 80s, with the largest paint around 4.5 to 5.5 seconds. In the runs since, most scores sit in the mid-to-high 90s with the largest paint around 2 to 3 seconds. Blocking time is close to zero and layout shift is effectively nil.
Two honest caveats: several other changes merged that same evening, so the fonts change cannot take all the credit; and the "before" sample is only a few runs. That is the normal state of real-world measurement. It is still far better than no measurement.
Reading the chart
- Look at the trend, not one run. A ten-point dip in one run that recovers in the next is noise.
- Look at the deploy lines. A drop that starts at a deploy and stays is a regression in that change.
- Compare with the seven-day median, which the dashboard shows next to the latest and previous values.
From measurement to budget
A speed budget is a limit you agree to stay within. A sensible starting budget for this site's measured pages, based on its own history:
| Metric | Budget |
|---|---|
| Performance score | 90 or above (seven-day median) |
| Accessibility score | 95 or above |
| Largest paint | 2.5 s or less |
| Blocking time | 100 ms or less |
| Layout shift | 0.05 or less |
Start by showing breaches on the dashboard. Once the numbers are stable, make the workflow fail when a budget is broken for two runs in a row, so a slow change gets the same red cross as a failing test.
What usually makes a page slow
- render-blocking fonts and stylesheets;
- pictures larger than they are displayed, or without width and height (which also causes layout shift);
- scripts loaded on pages that do not need them (this site loads its payment script only while payments are switched on);
- slow server responses, often from cold starts or work done before the page is sent.
Try it yourself
Run Lighthouse on your three most important pages today, three times each, and note the median. That is your baseline. Then set one budget, for the largest paint, and check it after every change for a month.