Chapter 7
How do you keep a site fast after launch?
Set three numbers, test them on every change, and fail the build when one slips. Sites get slow one script and one image at a time, not on launch day.
By turning speed into a number that fails the build. Pick the three Core Web Vitals thresholds, test them automatically on every change, and refuse to ship a change that breaks one. A site is rarely slow on launch day. It gets slow over the following year, one tracking script, one oversized hero image, and one "quick" embed at a time, and nobody notices because no single change was the one that did it. A budget notices.
This is a short chapter because the mechanism is simple. The discipline is in leaving it switched on.
What are you measuring?
Three things Google calls Core Web Vitals, measured on real visits and judged at the 75th percentile.
- Largest Contentful Paint (LCP). How long until the main content is on screen. Good is 2.5 seconds or less.
- Interaction to Next Paint (INP). How long the page takes to respond when someone taps or types. Good is 200 milliseconds or less.
- Cumulative Layout Shift (CLS). How much the page jumps around while it loads. Good is 0.1 or less.
They're a ranking signal, but that is the smaller reason to care. The larger one is who is on the other end: a patient on a phone, on a waiting-room or parking-lot connection, trying to find a phone number or an address. Chapter 1 scores a site 1 on performance when these are red on mobile in field data, and that wording is deliberate. The laptop on office wifi is not the test.
What usually makes a healthcare site slow?
Other people's code, then images, then fonts. Almost never the framework.
- Third-party scripts. Tag managers, chat widgets, session replay, review badges, map embeds, testing tools. Each one is a download, a parse, and work the browser has to do on every page, and each was added by someone solving a real problem that week. It's much the same list as chapter 5, and for the same reason: nobody is keeping count. The starter ships with one analytics tag that loads only after consent and a bot check that loads only on pages with a form. Location pages link out to directions instead of embedding a map.
- Images. A 4,000-pixel photo of the lobby, uploaded straight from the photographer and scaled down by the browser. The fix is a pipeline, not a policy: editors upload the original, and the site requests the size it needs, in a modern format, from the image CDN. In the starter every image also declares its width and height, so the page doesn't jump when it arrives.
- Fonts. Web fonts loaded from someone else's server hold text back or make it jump when they swap in. The starter uses one family, hosted with the site, so the swap moves nothing.
On a WordPress site the first item is usually a stack of plugins, each adding its own script and stylesheet to every page whether the page uses it or not. That's a large part of why a rebuild is fast on day one. It's not a reason it will stay fast.
What does a budget look like?
A config file with thresholds, run by the same automation that runs the tests.
The starter runs Lighthouse against three pages (the home page, a provider page, and the contact form) on every pull request. It fails the build if LCP is over 2.5 seconds, if CLS is over 0.1, or if Total Blocking Time is over 200 milliseconds. Total Blocking Time stands in for INP, which can't be measured without a real person tapping. The overall performance score is a warning below 90 rather than a failure, because the score moves a few points between runs, and a check that fails at random gets switched off.
That last point is the whole design problem. A budget has to be strict enough to catch a real regression and stable enough that nobody learns to ignore it. Three hard numbers and one soft one is where the starter landed.
What do you do when a change breaks the budget?
Treat it as a decision, in writing, not as a bug to work around.
Most of the time the change gets fixed: the image gets sized, the script gets loaded only where it's needed. Sometimes the business case is real, a scheduling widget on the booking page, say. Then the answer is to load it on that page only, after consent if it tracks, and accept the cost there. What shouldn't happen is the threshold being raised quietly to make the check pass. If the number moves, someone should be able to say when and why.
It's the same arrangement as the consent gate in chapter 5. Adding a third-party script is a code change that goes through review, so the question gets asked every time.
What about real visitors?
The automated check runs in a lab: one machine, a fixed connection, an empty cache, and in the starter's config a desktop profile. It catches regressions. It doesn't tell you what patients get.
That's field data, and it's free. Search Console's Core Web Vitals report shows the numbers for real visits, split by mobile and desktop and grouped into sets of similar pages. It needs a few weeks of traffic before it says anything, which is why chapter 9 has it on the list for the month after launch. Look at it monthly after that. If mobile LCP on provider pages drifts from good to needs improvement, something changed on that template, and the pull-request history will tell you what.
Checklist
Set the budget
Keep the usual culprits out
Watch the field
Companion code in the Healthcare Sanity Starter: lighthouserc.json (the budget), .github/workflows/ci.yml (where it runs).