Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

Measuring time-to-first-download, not just page load

PageSpeed gave my site a decent score and I still had a problem. People were landing on the page, pasting a link, and waiting. The page had loaded. The tool had not done its job yet. That gap is what I now measure. I ca

PageSpeed gave my site a decent score and I still had a problem. People were landing on the page, pasting a link, and waiting. The page had loaded. The tool had not done its job yet.

That gap is what I now measure. I call it time-to-first-download: the seconds from the moment a visitor arrives until the download button for their video actually works. Everything before that moment is setup. Everything after it is the point of the site.

What the metric actually covers

Time-to-first-download has four parts on my site, ramrom.io, and each one can be slow on its own:

  1. The page loads: HTML, CSS and the small JavaScript engine.
  2. The visitor pastes a link and taps the button.
  3. My server calls the provider API to resolve the link.
  4. The quality list appears and the visitor taps download.

A fast page load only fixes step one. If the resolve call takes six seconds, the visitor still waited six seconds, whatever the score said. So I stopped optimising for the score and started timing the whole journey.

How I time it in the browser

I did not add a heavy analytics setup. The browser already gives me what I need. I record performance.now() when the page starts loading, then again at each step: when the page is interactive, when the resolve request is sent, when the response comes back, and when the first download link is shown.

The difference between the first and last timestamps is the number I care about. I log those timings to my own server in one small request, with no personal data — just the step name and the milliseconds. That keeps the measurement honest and the visitor anonymous.

What the numbers showed me

Three things surprised me.

First, my own page was rarely the slow part. The HTML and CSS are small, with no webfonts and no frameworks, so the page is usually interactive in well under a second on a decent connection. The slow part was the resolve call, because it depends on a third-party provider. Some days it answers in under a second. Other days it takes four or five.

Second, the quality list was costing time. I used to wait for every format before showing anything. Now I show the first usable quality as soon as it arrives and fill in the rest afterwards. The visitor can start downloading while the slower formats are still loading. That one change cut the measured time more than any CSS trick ever did.

Third, the worst numbers came from my own testing habits. On my fast home connection everything looked fine. On a slow mobile connection — the kind many of my visitors actually use — the same journey took three times longer. I now test on a throttled connection before I call anything fast.

The fixes that actually moved the number

A few small changes did most of the work:

  • I cache a resolve response for 60 seconds, so pasting the same link twice does not burn a second API call.
  • I cap the provider call with a timeout, so one slow API cannot hang the page.
  • I show a skeleton loader while resolving, so the visitor can see the tool working instead of staring at a dead button.
  • I defer JavaScript not needed for the first paint, but never the code that handles the paste and the button.

None of this is clever. It is just measuring what the visitor is actually waiting for, instead of the number on a report.

Why I still look at page load

Page load still matters: a page that takes ten seconds to appear loses people before they ever paste a link. But it is the start of the journey, not the whole journey. A tool site is judged on how quickly it does the job, and the job starts when the visitor arrives and ends when the file starts downloading.

If you build a tool, time that whole trip. You will probably find the slow part is not where you expected it to be.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.