Lesson 2 · Unit 04
Budgets and monitoring
A limit per page, a check in CI, numbers from real users
What you practise
- A budget per page, measuring real users, a regression caught in CI
Try a question from this lesson
Pick one
A site was fast at launch. In a year, 60 pull requests each added "only" 10 KB of JavaScript, and none was questioned. What does that show about how sites get slow?
Correct answer
In small steps that nobody is asked to stop
Why
60 × 10 KB is 600 KB, more than many whole pages, and no single change was worth an argument. Slowness is rarely one decision. That is why the defence has to be automatic: something that counts on every change.
The ideas
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
A performance budget
A budget is a limit agreed in advance, per page, on things that can be counted: kilobytes of JavaScript, image weight, number of requests, a lab LCP.
A check compares every build with it. Over the limit, the build fails, and someone has to decide: make room, or raise the limit on purpose.
It turns "keep it fast" into a number that can say no.
{
"page": "/product",
"budget": {
"js_kb": 300,
"images_kb": 500,
"requests": 40
}
}Concept
Measuring real users
A budget guards what can be counted before release. What visitors actually got is known only from the field.
The browser records its own timings. A few lines of script in the page observe them and send each value to your server: real user monitoring. send here stands for that upload. In general the last value sent is the page's LCP.
Store every sample with its page, device type and release, so groups can be compared.
new PerformanceObserver((list) => {
for (const entry of list.getEntries()) {
send("LCP", entry.startTime);
}
}).observe({
type: "largest-contentful-paint",
buffered: true,
});10 more exercises in the app
- 3× type the answer
- 3× multiple choice
- 1× fill the blanks
- 1× true or false
- 1× match the pairs
- 1× order the lines
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.