You open a promo link from a WhatsApp group, on a cheap phone with two bars of signal. The screen is white. Three seconds, five seconds, still white. Most people don't wait much longer than that: they press back and look for another shop.
What you feel there is called web performance: how fast a page appears, and how quickly that page responds while people use it. Think of the checkout line at a minimarket. When the line is short, you pay and go home. When the line is very long, many people put their basket down and leave, even though they had already chosen their things. A slow page is that long line, and its visitors are the shoppers: they leave before they see what is on the page.
Load time and bounce
Two terms first:
- Load time is the time from when a visitor opens a link until the page is ready to use. It is usually written in milliseconds (ms): 1,000 ms = 1 second.
- A bounce is a visitor who arrives and leaves without doing anything: no click, no other page. The bounce rate is the percentage of visits that end in a bounce.
The longer the load time, the more visitors bounce. They close the tab, press back, or go to a competing site.
A little slower, a lot more leave
The two findings quoted most often:
| Who | What they found |
|---|---|
| Google (research on mobile pages, 2017) | load time going from 1 second to 3 seconds: the probability of a bounce rises 32% |
| Amazon (internal experiments, 2006) | every extra 100 ms of latency: sales drop by about 1% |
Latency is waiting time. In Amazon's finding, it means the extra time before the page responds. 100 ms is a tenth of a second, about as long as one blink of an eye. But across millions of sales, 1% of sales is a lot of money. The Amazon figure comes from A/B tests in 2006. A former Amazon engineer, Greg Linden, described them in a blog post and in class slides. The data was never published, so treat it as an illustration, not an exact rule.
The 32% is only for going from 1 to 3 seconds. In the same Google research, when load time goes from 1 to 5 seconds, the probability of a bounce rises 90%. From 1 to 10 seconds, it rises 123%.
Google also judges page speed. It measures user experience with three numbers called Core Web Vitals (they have their own lesson). Those three numbers are one of its ranking signals: the things that help decide the order of pages in search results.
Put a label on the load time
A raw number like 2,500 ms is easier to read with a label. The four labels below are our own, made for the exercise, not an official standard:
| Load time | Label |
|---|---|
| up to 1,000 ms | "excellent" |
| above 1,000 up to 3,000 ms | "acceptable" |
| above 3,000 up to 5,000 ms | "poor" |
| above 5,000 ms | "critical" |
The function below turns a load time into one of those labels. The last five lines try it, and each result is in the comment:
function calculateLoadImpact(loadTimeMs) {
if (loadTimeMs <= 1000) return "excellent";
if (loadTimeMs <= 3000) return "acceptable";
if (loadTimeMs <= 5000) return "poor";
return "critical"; // the rest: above 5,000 ms
}
console.log(calculateLoadImpact(800)); // "excellent"
console.log(calculateLoadImpact(1000)); // "excellent"
console.log(calculateLoadImpact(2500)); // "acceptable"
console.log(calculateLoadImpact(3001)); // "poor"
console.log(calculateLoadImpact(7000)); // "critical"
- The limits are checked from the smallest. The first
ifthat matches returns right away, so the function stops there and the lines after it don't run. Theiflines have no braces here, because each one holds a single statement. <=means "less than or equal to". So 1,000 is still"excellent", because 1,000 <= 1,000 is true.- 3,001 fails the check
<= 3000, then passes<= 5000, so its label is"poor". - The last line inside the function needs no
if. If noifmatched, the number must be above 5,000.
Fast on your laptop isn't fast for everyone
Many visitors open the web on a cheap phone with a signal that keeps changing. A page that appears in 1 second on a laptop with office Wi-Fi can take 5 seconds on their phone. Making a page fast means making a page everyone can use, not only people with expensive phones.
Pages also get slower little by little, because every new feature adds images and JavaScript. In the next lessons you learn to measure page speed, read the numbers, and cut what makes the page slow.
⚠️ Missteps when you start caring about speed
- Testing only on a fast laptop. Office Wi-Fi and a new laptop aren't what most visitors have. Chrome DevTools (the developer tools in the Chrome browser) can imitate a slow network and a slow CPU (processor). This feature is called throttling.
- "We'll optimise later." A page that is already heavy is hard to make lighter afterwards. Set limits for speed and page size from the start. Those limits are called a performance budget.
- Polishing small things, missing the big one. Arguing about whether
foris faster thanforEachmeans nothing when the same page has a 5 MB image. - Wrong limits in the exercise. Use
<=, not<. With<, 1,000 falls into"acceptable", when it should be"excellent".
TL;DR: Load time is the time until a page is ready to use, and a bounce is a visitor who leaves without doing anything. The slower the page, the more visitors bounce. Google's research found that when load time goes from 1 to 3 seconds, the probability of a bounce rises 32%. Amazon found that every extra 100 ms of latency (waiting time) cuts sales by about 1%. Google also uses Core Web Vitals, three numbers for user experience, as one of its ranking signals (things that help decide the order of search results). In the exercise, label the load time with if and <=, starting from the smallest limit: up to 1,000 ms "excellent", up to 3,000 ms "acceptable", up to 5,000 ms "poor", the rest "critical". Test on phones and slow networks too, not only on your laptop.
⚡ Load time and bounce
Meaning: Load time is the time from opening a link until the page is ready to use, usually written in milliseconds (1,000 ms = 1 second). A bounce is a visitor who arrives and leaves without doing anything: no click and no other page.
⚡ A little slower, a lot more leave
Guess first: a page that used to appear in 1 second now needs 3 seconds. By what percentage does the probability of a bounce rise?
It rises 32%, according to Google's research on mobile pages (2017). Amazon also found that every extra 100 ms of latency (waiting time before the page responds) cuts sales by about 1%.
Meaning: The slower the page, the more visitors leave before they see its content.
⚡ Put a label on the load time
Write:
function calculateLoadImpact(loadTimeMs) {
if (loadTimeMs <= 1000) return "excellent";
if (loadTimeMs <= 3000) return "acceptable";
if (loadTimeMs <= 5000) return "poor";
return "critical";
}
Guess first: what does calculateLoadImpact(1000) return?
"excellent", because 1,000 <= 1,000 is true (<= means less than or equal to). If the code used <, 1,000 would fall into "acceptable".
Meaning: This function puts a label on a load time in milliseconds. The limits are checked from the smallest. The first if that matches returns right away, so the lines after it don't run. The if lines have no braces here, because each one holds a single statement. The last line inside the function catches the rest: load times above 5,000 ms.
⚡ Test on phones and slow networks too
Meaning: A page that appears in 1 second on an office laptop can take 5 seconds on a cheap phone with a weak signal. Chrome DevTools (the developer tools in the Chrome browser) can imitate a slow network and a slow CPU (processor). This feature is called throttling.