Frontend speed: which metrics matter and where to start
Scoring 100 in Lighthouse is not hard. Fix your image dimensions, add a couple of attributes, configure caching — and the green circle appears.
The problem is that the score is not directly tied to how the site feels. I have seen sites scoring 95 that feel sluggish, and sites at 70 that are usable instantly.
So I want to frame this differently: not around the score, but around the question of what the user actually perceives and which work affects it.
Users perceive three things
There are dozens of metrics, but in practice a user gets an answer to only three questions.
"Is anything visible?" This is when the main content paints. If a blank white screen sits there for several seconds, the user concludes the site is broken.
"Can I click?" The page may be painted while JavaScript has not loaded and the buttons do not respond. This is the most irritating state, because the site looks ready and is not.
"Why is everything jumping?" An image loads late, the text shifts, the button you were aiming at moves. Technically that is not speed, but the user experiences it as exactly that.
Every other metric is a way of measuring those three. When you start optimising, ask yourself: which of the questions am I improving?
Set up your measurement conditions properly
This is the first and most commonly skipped step.
You open the site on a fast laptop, on fast internet, with a warm browser cache. Your user is on a mid-range phone, on mobile data, for the first time.
So take every measurement under constraints: in your browser tools, throttle the CPU by four times and drop the network to mobile speed. The numbers will be completely different — and those are the real ones.
A second detail: do not measure against a local dev server. Locally the code is unminified, caching is not configured and there is no network latency. Measure the production build only.
The biggest lever: JavaScript weight
On most sites the main bottleneck is the amount of JavaScript being shipped.
The reason is that JavaScript is expensive three times over: it has to be downloaded, then parsed, then executed. An image is only downloaded, and it does not block the main thread.
The first step is to see what is being sent. Read the bundle size list your build prints. If a number looks unexpectedly large, open it in an analyser.
The three most common causes:
Importing a whole library. A large package gets pulled in for one function. Many libraries offer a granular import path.
Date and localisation libraries. They often bring data for every locale. Modern browsers have Intl built in, and it is enough in most cases.
A component needed on one page loading everywhere. Load heavy components — charts, editors, maps — on demand.
If you use a server-rendering framework, the most effective move is different: push the client boundary lower. Non-interactive components should never reach the client at all — I wrote about that in detail in a separate article.
Second: images
Images are usually the largest part of a page by bytes, but they do less damage than JavaScript, because the browser fetches them in parallel.
Three things are enough.
Dimension attributes. Every image should carry width and height. Without them the browser reserves no space until the image loads, and the page jumps.
Lazy loading — but not above the fold. For images below the fold, loading="lazy" helps. For the hero image at the top it hurts: that is the most important image, and delaying it degrades your most important metric.
A modern format and the right size. Putting a 3000-pixel-wide image into a 400-pixel slot is the most common waste there is.
Third: fonts
Fonts look like a small thing, but they block text from appearing.
Two settings solve most of the problem.
The first is font-display: swap. While the font loads, the browser shows the text in a system font. The text shifts once, but the user is not staring at an empty screen.
The second is a real fallback stack. In many projects font-family holds one name and sans-serif. Choose a fallback with metrics close to your primary font and the swap becomes almost invisible.
Also, serve fonts from your own domain. Loading from a third-party host adds an extra DNS lookup and connection time.
Wasted work
A few things absorb time and return almost nothing.
Shaving a couple of kilobytes off CSS. Modern tooling strips unused CSS itself, and what remains is usually small.
Trying to replace every library. Measure first. Usually one large dependency is slowing you down, not ten.
Pixel-perfect optimisation of every image. Fix the three biggest and stop.
Chasing the last five Lighthouse points. Those points are usually details no user will ever notice.
The general rule: before each optimisation measure, then fix the biggest one, then measure again. Walking a checklist top to bottom wastes time.
A practical order
If your site is slow, go in this order:
- Measure the production build under constraints. Write the numbers down.
- Look at the bundle sizes in your build output. Find the largest.
- Fix one thing — usually excess JavaScript.
- Measure again. Is there a difference?
- Move to images: dimension attributes and the hero image.
- Move to fonts:
swapand the fallback stack. - Stop.
Seven steps. This is usually a few hours of work rather than days — and the effect is considerably larger than chasing a score.
One last piece of advice: watch speed continuously, not once. Sites do not get slow from one big mistake, they get slow from dozens of small additions. The habit of checking bundle size on every release is the cheapest protection available.