completefrontend

Predict the outputMedium

Which priority does Chrome give each image?

The tea shop's home page has five pictures: a small logo, a hero with fetchpriority="high", a picture of cups under it, a picture of tea leaves further down, and a kettle with loading="lazy" far down the page. The server takes a few hundred milliseconds to send each picture. Which pictures does Chrome ask for before you scroll, what priority does each start at, and what is the last priority Chrome gives it? And what does the page log?

index.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Leaf and Kettle</title>
  <style>
    body { margin: 0; font-family: system-ui, sans-serif; }
    img { display: block; width: 100%; height: auto; }
    #logo { width: 48px; }
    #leaves { margin-top: 1200px; }
    #kettle { margin-top: 4000px; }
  </style>
</head>
<body>
  <img id="logo" src="logo.svg" alt="Leaf and Kettle" width="48" height="48">
  <img id="hero" src="hero.svg" alt="This week's tea: mint" width="400" height="250" fetchpriority="high">
  <img id="cups" src="cups.svg" alt="Our cups" width="400" height="250">
  <img id="leaves" src="leaves.svg" alt="Tea leaves drying" width="400" height="250">
  <img id="kettle" src="kettle.svg" alt="A copper kettle" width="400" height="250" loading="lazy">
  <script>
    addEventListener("load", () => {
      const asked = performance.getEntriesByType("resource").map((entry) => entry.name.split("/").pop());
      console.log("Asked for before you scroll: " + asked.sort().join(", "));
    });
  </script>
</body>
</html>
logo.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48" height="48">
  <rect width="48" height="48" fill="#3f6f31"/>
  <text x="24" y="24" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="8" fill="#fff">L</text>
</svg>
hero.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 250" width="400" height="250">
  <rect width="400" height="250" fill="#6f8f3a"/>
  <text x="200" y="125" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="42" fill="#fff">Mint tea</text>
</svg>
cups.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 250" width="400" height="250">
  <rect width="400" height="250" fill="#a0702a"/>
  <text x="200" y="125" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="42" fill="#fff">Our cups</text>
</svg>
leaves.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 250" width="400" height="250">
  <rect width="400" height="250" fill="#7fa05a"/>
  <text x="200" y="125" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="42" fill="#fff">Tea leaves</text>
</svg>
kettle.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 250" width="400" height="250">
  <rect width="400" height="250" fill="#b0502a"/>
  <text x="200" y="125" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif" font-size="42" fill="#fff">Kettle</text>
</svg>

Chrome loads these files from a server on the same computer, index.html at /, in a fresh profile with an empty cache, on a phone's screen (412 by 823 CSS pixels), with no network or CPU slowdown. The server holds back logo.svg for 300 ms, hero.svg for 400 ms, cups.svg for 500 ms, leaves.svg for 600 ms and kettle.svg for 700 ms before it answers.

  1. You open the page in Chrome and don't scroll.
  2. When the page has loaded, its script logs the files it asked for.

The answer

Work out what Chrome does with the page: every line it logs, in order, and how it treats each file. Then check.

Checking your sign-in…