How Chromium loads resources
Follow one request through Chrome's source: the preload scanner, how a priority is picked, the network service, and the two schedulers that hold requests back.
- 01Follow a request through ChromeName each part it passes: the preload scanner, the fetcher that picks its priority, the renderer's scheduler, and the network service.
- 02Say why a request waitedTell tight mode in the renderer from the network service's limits, and say how HTTP/2 and a slow network change them.
- 03Work out a priority from Chrome's rulesApply the type, async, first-five and layout rules, and read one priority under its DevTools, Blink and network names.
One photo's trip through Chrome
Asha opens the Mint tea page on her phone. For a moment, her screen stays blank. Then the heading and a big photo of mint tea appear. The other teas follow below it.
Ravi built the page, and he has read the earlier lessons. He knows what Chrome did. The preload scanner found the photo early. Chrome gave it a priority. Some files waited their turn. Now he has a new question. Who inside Chrome made each of those choices? And where, exactly, can a request wait?
Chrome is built from Chromium, which is open source, so the answer can be read. This lesson follows one request, the photo mint.jpg, through Chrome's own code. Every line it quotes comes from the release the course records with, Chrome 157.0.8103.52. Every number comes from a real visit. Here are four moments from one visit over HTTP/2:
// One recorded visit to the Mint tea page, in ms after it started.const photo = { found: 37.7, leftRenderer: 39.4, lastByte: 447.5, painted: 680 }; console.log(`Chrome asked for mint.jpg at ${photo.found} ms.`);console.log(`It left the page's renderer at ${photo.leftRenderer} ms.`);console.log(`Its last byte arrived at ${photo.lastByte} ms.`);console.log(`It was painted at ${photo.painted} ms.`);- Line 1 is a comment. Every time is in milliseconds (ms) after the visit started.
- Line 2 holds four times the course recorded for the photo.
- Lines 4 to 7 print
Chrome asked for mint.jpg at 37.7 ms.,It left the page's renderer at 39.4 ms.,Its last byte arrived at 447.5 ms.andIt was painted at 680 ms.
A renderer is the process that runs one page: its HTML, CSS and JavaScript. You met it in Processes and threads. The photo left it less than 2 ms after Chrome asked for it. Then it took about 400 ms to arrive. It was painted later still, because a slow script in the head held the first paint back, as in Render-blocking and parser-blocking resources. Here is the whole trip, next to what Asha saw:
You leave a parcel in your office's outgoing tray. A clerk spots it and stamps it first class or second class. In the morning rush, the office keeps second-class post back, so the urgent post goes first. Then the parcel goes to the post office, a separate building with its own rules. It sends only a few parcels to one street at a time.
- In real life: The address written on the parcel
- In Chrome: The tag in the HTML, like
<img src="mint.jpg"> - In real life: The clerk who spots it in the tray
- In Chrome: The preload scanner
- In real life: The first-class or second-class stamp
- In Chrome: The priority, picked by the ResourceFetcher
- In real life: The office holding second-class post in the rush
- In Chrome: The renderer's scheduler, in tight mode
- In real life: The post office, in another building
- In Chrome: The network service, with a scheduler of its own
A request is found by the preload scanner and labelled with a priority. Then it may wait twice: once in the page's renderer, and once in the network service. Each of those steps is a few hundred lines of Chrome's code. The sections below read them in the order the photo met them.
Inside the preload scanner
The trip starts with finding the file. HTML parsing and the preload scanner showed what the scanner finds: the files the HTML names. The JavaScript course told the same story from the script's side, in From HTML to running script. Now look at when the scanner runs, and what it reads.
Chrome's HTML parser lives in html_document_parser.cc. Each time a piece of HTML arrives from the network, the parser's Append() function gets it. Here is the part that wakes the scanner. Lines that start with // are comments, and -> calls a function on an object:
if (preload_scanner_) { preload_scanner_->AppendToEnd(source); if (task_runner_state_->GetMode() == kAllowDeferredParsing && (IsPaused() || !task_runner_state_->SeenFirstByte())) { // Should scan and preload if the parser's paused waiting for a resource, // or if we're starting a document for the first time (we want to at least // prefetch anything that's in the <head> section). ScanAndPreload(preload_scanner_.get()); }}In plain words, line by line:
- Line 1: if this page has a preload scanner,
- Line 2: hand it the new piece of HTML.
- Lines 3 and 4: if the parser is paused, waiting for something such as a script, or if this is the page's first piece,
- Lines 5 to 7 are Chrome's own comment. They say why: the scanner should at least look through the head.
- Line 8: scan the piece, and start fetching the files it names.
So the scanner runs at two moments: on the first piece of the page, and whenever the parser is stuck. In this release, it runs on the page's main thread, in short bursts. Chrome has code to move it to a thread of its own, but that feature is off by default.
A second reader with its own tokenizer
The scanner doesn't share the parser's work. It has its own tokenizer, the part that cuts HTML into tags. It reads the same bytes again, tag by tag. For each tag, it keeps only the attributes that name a file or change how it's fetched. For an <img>, those include src, srcset, sizes, loading, fetchpriority, and the width and height. It reads <link rel="preload"> tags too, from Resource hints. It also notes a few things on the way:
- The first
<base>tag wins. Every later address is read against it. - Anything inside a
<template>is skipped: it isn't part of the page yet. - An image with
loading="lazy"gets no request at all. It waits for layout, like any lazy image. - The line and column of each tag are noted. DevTools shows the line as the request's initiator.
A cook is handed a long recipe. A helper reads it once, quickly, and writes a shopping list. For each ingredient, the list says what, how much, and which shop. The helper doesn't cook anything. And when the recipe says "pick the berries later, if there's time", the helper leaves them off the list.
- In real life: The recipe
- In Chrome: The HTML
- In real life: The helper's quick read
- In Chrome: The scanner's own tokenizer
- In real life: One line of the list: what, how much, which shop
- In Chrome: One request: the address, the kind of file, its width and height
- In real life: "Pick the berries later, if there's time"
- In Chrome:
loading="lazy": no request now
Here is the scanner at work on the HTTP/1.1 visit. The whole page, 1,454 bytes, reached the parser in one piece. At 24.3 ms, one scan read all of it. Within the next millisecond, Chrome asked for all 17 files the page names. The parser was held up. It started at line 1, reached menu.js on line 8, and stopped. menu.js is a plain script, and the server took 600 ms to send it. The parser went on at 639.5 ms, and reached the photo's tag at 639.8 ms:
The scanner asked for the photo 615 ms before the parser reached its tag. Only the parser builds the page, the first step of the critical rendering path. Without the scanner, the photo couldn't have been asked for until then. That's why it matters: on this page, the scanner gave the photo a head start of more than half a second.
One more detail leads to the next section. The scanner passes each image's width and height on with its request. Chrome uses them to pick the request's priority.
How Chrome picks a priority
Every request gets a priority: a label that says how urgent it is. You saw them in How browsers prioritize requests. Chrome picks it in one function, ComputeLoadPriority, in resource_fetcher.cc. Chrome's notes on loading call that file "the core prioritization logic". The function starts from the kind of file:
case ResourceType::kCSSStyleSheet:case ResourceType::kFont: return ResourceLoadPriority::kVeryHigh;case ResourceType::kScript: return ResourceLoadPriority::kHigh;case ResourceType::kImage: return ResourceLoadPriority::kLow;In plain words, line by line:
- Lines 1 and 2: a stylesheet or a font
- Line 3: starts at
kVeryHigh, which DevTools calls Highest. - Lines 4 and 5: a script starts at
kHigh, which DevTools calls High. - Lines 6 and 7: an image starts at
kLow, which DevTools calls Low.
These names come from Blink, the part of Chrome that runs pages inside the renderer. DevTools shows the same five levels with shorter names.
Then the function changes the starting point, rule by rule, in this order:
- An image on the screen goes to High. At first, Chrome doesn't know where an image will be, so this rule only matters later.
- An async or defer script drops to Low. A script or stylesheet the scanner found after the first image drops to Medium.
- The
fetchpriorityattribute moves it.highlifts it to at least High.lowdrops it to Low, or to High for an early stylesheet. A request that blocks rendering is lifted to at least High. - The first five large images the scanner finds go up to Medium. Large means more than 10,000 square pixels. This is where the scanner's width and height come in.
At the gate, each ticket shows a boarding group. The kind of ticket decides it. The first few families with small children are moved up a group. A passenger can ask to board early: the staff move them up to group two, but no further. Later, staff may call a few waiting passengers forward. They never send anyone back.
- In real life: The group printed on the ticket
- In Chrome: The priority from TypeToPriority
- In real life: The first few families, moved up a group
- In Chrome: The first five large images, raised to Medium
- In real life: Asking to board early: group two, no further
- In Chrome:
fetchpriority="high": High, never Highest - In real life: Calling waiting passengers forward, never back
- In Chrome: The update after layout, which only raises
Here are three images from the Mint tea page, through those rules:
mint.jpg was the first large image, so it went up to Medium. jasmine.jpg was the sixth: the five places were taken, so it stayed Low. card.svg is a 40 by 24 icon, which is 960 square pixels. That's small, so it didn't count at all.
The update after layout
The bottom row of the picture comes later, after layout: the step where Chrome works out where every element goes. Then Chrome checks every image that's still loading. If one is on the screen, rule 1 gives it High, and Chrome sends the new priority on. On the HTTP/1.1 visit, that happened at 646.4 ms, to six teas at once.
Two rules keep this calm. Images that have already arrived are skipped: mint.jpg had arrived at 441 ms, so it stayed Medium. And a priority only ever goes up. Chrome's comment there says why: so an image that moves in and out of view doesn't keep changing. Try every rule on the page's own files:
- line 199TypeToPriority: an image starts at Low. Low
- line 776Large image number 1 of the first five: up to Medium. Medium
The rules give Medium. DevTools recorded Medium at the start, the same. It stayed at Medium: it had already arrived when layout came.
One priority, three names
Once the priority is picked, it crosses into the network service, which uses the network's own names. Over HTTP/2, Chrome turns it into a priority header on the request, as RFC 9218 defines. Its urgency, u, runs from 0, the most urgent, to 7. The i means the file is useful a piece at a time. The course's server noted the header each request arrived with. Read each row across:
| DevTools shows | Blink calls it | The network service calls it | The header the server got |
|---|---|---|---|
| Highest | kVeryHigh | HIGHEST | u=0, for shop.css. |
| High | kHigh | MEDIUM | u=1, for menu.js. |
| Medium | kMedium | LOW | u=2, i, for mint.jpg. |
| Low | kLow | LOWEST | i, for card.svg: urgency 3 is the default, so it's left out. |
| Lowest | kVeryLow | IDLE | u=4, by Chrome's rule. This page had no such file. |
Notice that the names don't line up. The network's MEDIUM is DevTools' High. Keep that in mind for the network service's rules, two sections from here.
The network service: one door for every tab
The photo now has a priority. But the renderer can't send it. Renderers never talk to the network themselves. One part of Chrome does that for every tab: the network service.
Its README, the notes file at the top of its folder services/network, opens plainly: "This is a service for networking." It says only the lowest level of networking belongs there: "http, sockets, web sockets". Where it runs depends on the device:
- On most platforms, it gets a process of its own, a utility process that holds nothing else. If it crashes, Chrome starts it again in a new one.
- On Android, it runs inside the browser process, on a thread of its own. The README calls this the default on Android "because of some unresolved issues".
The README adds one rule for the code inside: "every PostTask, thread hop and process hop (IPC) should be counted carefully". A hop is a message passed to another thread or process. Each one costs time, so the network service keeps them few.
At a bank, customers never walk into the vault. They pass a slip through a window to a cashier behind glass. One cashier serves every customer. She decides whose slip goes next, and writes each step in a log book.
- In real life: Each customer at the window
- In Chrome: Each page's renderer
- In real life: The slip passed through the window
- In Chrome: A request sent to the network service
- In real life: The cashier behind glass
- In Chrome: The network service, in a process of its own
- In real life: The cashier's log book
- In Chrome: The NetLog
Asking before starting
Inside the network service, each request gets a URLLoader, an object that carries it from start to end. Before it sends anything, the loader asks the network service's scheduler whether it may start:
bool defer = false;if (resource_scheduler_client_) { resource_scheduler_request_handle_->WillStartRequest(&defer);}if (defer) url_request_->LogBlockedBy("ResourceScheduler");else url_request_->Start();In plain words, line by line:
- Line 1 makes a flag called
defer, "wait", and sets it to false. - Line 2: if this request has a scheduler to ask,
- Line 3: ask the scheduler. If the request must wait, the scheduler sets
deferto true. - Lines 5 and 6: if it must wait, write "blocked by ResourceScheduler" in the log, and don't start.
- Lines 7 and 8: otherwise, start the request now.
A request that waits is started later, when the scheduler calls it back. The next section covers the scheduler's rules.
The network service's own log
Every step of every request goes into the network service's log, the NetLog. You can save one yourself: open chrome://net-export in a new tab, start logging, and load a page in another tab, as Chromium's guide describes. The course started Chrome with the --log-net-log switch instead, which logs from the very start. Pick a request to see its milestones:
- 28 msThe request arrives in the network service.
REQUEST_ALIVE BEGIN - 28 msIts job starts.
URL_REQUEST_START_JOB BEGIN - 28 msIt looks in the HTTP cache.
HTTP_CACHE_GET_BACKEND BEGIN - 28 msIt asks for a connection.
HTTP_STREAM_REQUEST BEGIN - 36 msIt gets a connection.
HTTP_STREAM_REQUEST END - 36 msIt sends the request.
HTTP_TRANSACTION_SEND_REQUEST BEGIN - 440 msThe response's headers arrive.
HTTP_TRANSACTION_READ_HEADERS END - 440 msThe last byte is in. The request is done.
REQUEST_ALIVE END
The photo went straight through. It arrived at 28 ms, found no reason to wait, and was sent as soon as it had a connection.
mint.jpg went straight through. It arrived, looked in the HTTP cache, got a connection and was sent. card.svg arrived and was blocked at once. So the network service is more than a door: it decides who goes through first.
Two places a request can wait
The course loaded the same page two more ways: over HTTP/1.1, and over HTTP/2 with Chrome told to rate the network as 3G. Same page, same priorities. Here are five files from the HTTP/1.1 visit and the HTTP/2 visit you followed above:
<body>.Most files waited in the renderer, the thin line, for over 600 ms. Over HTTP/1.1, three of them also waited in the network service. Over HTTP/2, none did. Two schedulers made those waits. Take them one at a time.
In the renderer: tight mode
The first is Blink's ResourceLoadScheduler. There's one for each frame: the page, or an iframe inside it. Every page starts in tight mode, the strict phase you met in lesson 5.4. Tight mode ends when the parser inserts the <body> element, which loosens the scheduler. Here are its limits:
constexpr size_t kTightLimitForRendererSideResourceScheduler = 2u;constexpr size_t kTightMediumLimitForRendererSideResourceScheduler = 2u;constexpr size_t kLimitForRendererSideResourceScheduler = 1024u;In plain words, line by line:
- Line 1: in tight mode, two requests below High may be running.
- Line 2: on top of that, two Medium requests may always run.
- Line 3: in normal mode, the limit is 1,024. In practice, that's no limit.
The count on line 1 includes every running request it could throttle, even the High ones. Here is the check as a small model in JavaScript:
// A small model of the renderer's tight-mode check, written for this lesson.function mayStart(priority, running) { if (priority === "High" || priority === "Highest") return true; const medium = running.filter((p) => p === "Medium").length; if (priority === "Medium" && medium < 2) return true; return running.length < 2;} const running = ["Highest", "High", "Medium", "Medium"]; // shop.css, menu.js, mint.jpg, black.jpgconsole.log(`chamomile.jpg: ${mayStart("Medium", running) ? "starts" : "waits"}`);console.log(`card.svg: ${mayStart("Low", running) ? "starts" : "waits"}`);- Line 1 says what this is: a model written for the lesson, not Chrome's own code.
- Line 3: High and Highest always start. Below High, tight mode's limit applies.
- Lines 4 and 5: a Medium request starts while fewer than two Medium ones are running.
- Line 6: anything else starts only while fewer than two requests are running.
- Line 9 is the moment right after the scan:
shop.css,menu.js,mint.jpgandblack.jpgwere running. - Lines 10 and 11 print
chamomile.jpg: waitsandcard.svg: waits.
That's what the recording shows. On the HTTP/1.1 visit, four files left the renderer at once. chamomile.jpg and green.jpg left at 441.4 ms, as soon as mint.jpg and black.jpg had finished. The other eleven left between 639.4 and 642.4 ms, as the parser reached <body>. Not everything waits in tight mode, though: a fetch() is never throttled there.
In the network service: delayable requests
The second scheduler is the network service's ResourceScheduler. It keeps one list for each tab. Its code says so: "Each client represents a tab." It calls some requests delayable: they may be held back. Two lines set who, and how many:
static const size_t kMaxNumDelayableRequestsPerHostPerClient = 6;static const net::RequestPriority kDelayablePriorityThreshold = net::MEDIUM;In plain words, line by line:
- Line 1: a delayable request waits while six of its tab's requests are already going to its server.
- Line 2: a request below the network's
MEDIUMis delayable. That's below DevTools' High: the same line tight mode draws.
A third limit lives in another file: ten delayable requests in all, for each tab. The network service checks every waiting request in ShouldStartRequest. A request starts at once when:
- it's at High or above;
- or its server can order requests itself. That's a server Chrome knows speaks HTTP/2, or has offered HTTP/3.
Otherwise, it starts only while the tab has fewer than ten delayable requests going, and fewer than six going to that server. Here is that check as a model too:
// A small model of the network service's check, written for this lesson.function mayStart(priority, goingToThisServer, server) { if (priority === "High" || priority === "Highest") return true; if (server === "HTTP/2") return true; return goingToThisServer < 6;} console.log(`card.svg over HTTP/1.1: ${mayStart("Low", 6, "HTTP/1.1") ? "starts" : "waits"}`);console.log(`card.svg over HTTP/2: ${mayStart("Low", 6, "HTTP/2") ? "starts" : "waits"}`);console.log(`rooibos.jpg, now High: ${mayStart("High", 6, "HTTP/1.1") ? "starts" : "waits"}`);- Line 1 says what this is: a model written for the lesson. It leaves out the limit of ten.
- Line 3: High and Highest always start.
- Line 4: an HTTP/2 server orders requests itself, so they start.
- Line 5: otherwise, a request starts while fewer than six are going to its server.
- Lines 8 to 10 print
card.svg over HTTP/1.1: waits,card.svg over HTTP/2: startsandrooibos.jpg, now High: starts.
A shopping centre's car park has a barrier. Each shop has six spaces, and the guard lets a car in only when its shop has a free one. Ambulances always drive straight in. A shop with its own loading bay sorts its own visitors, so its cars go in too. But on a stormy day, the guard holds back every car that isn't an ambulance.
- In real life: A car waiting at the barrier
- In Chrome: A delayable request: below High
- In real life: Six spaces for each shop
- In Chrome: Six of a tab's requests going to one server
- In real life: Ambulances, which always drive in
- In Chrome: Requests at High and above
- In real life: A shop with its own loading bay
- In Chrome: An HTTP/2 or HTTP/3 server, which orders requests itself
- In real life: A stormy day
- In Chrome: A network Chrome rates 3G or slower
All three lines of the model happened in the recording. Over HTTP/1.1, seven files reached the network service and waited: the six payment icons and rooibos.jpg. rooibos.jpg was let go at 646.4 ms, the moment layout raised it to High. Even then, all six connections to the server were busy, the HTTP/1.1 limit from HTTP/1.1 and HTTP/2. So it waited for a free one until 853.4 ms. The icons went as other requests to the server finished.
Over HTTP/2, nothing waited in the network service. The load event came at 1,065 ms instead of 1,664 ms. That's why it matters: on an HTTP/1.1 server, every file below High queues for six places, however small it is.
When HTTP/2 isn't enough
There's one catch. Chrome keeps estimating how fast the network is, and rates it from slow 2G to 4G. On a network it rates 3G or slower, it holds low requests back even on HTTP/2. That rule is on by default. On those networks, the limit is eight delayable requests, and each request at High or above counts as three of them.
The third visit tested it, with Chrome told to rate the network 3G. HTTP/2 again, yet five of the six icons waited in the network service. The load event came at 1,471 ms. And no request waits forever: after about 30 round trips, but never less than 15 seconds or more than 2 minutes, a waiting request starts anyway.
Here are all three visits, every file. Watch the icons at the bottom as you switch:
The network service held 7 of the page's 17 files: bank.svg until 1,044 ms, card.svg until 852 ms, rooibos.jpg until 646 ms, cash.svg until 1,049 ms, points.svg until 1,257 ms, voucher.svg until 1,049 ms, wallet.svg until 1,048 ms. The load event came at 1,664 ms.
The two schedulers are easy to mix up. Read each row across: one question, asked of each scheduler.
| Question | The renderer's ResourceLoadScheduler | The network service's ResourceScheduler |
|---|---|---|
| Where it runs | In the page's renderer, one for each frame. | In the network service, one list for each tab. |
| What it can hold back | Anything below High, while the page is in tight mode. | Anything below High, on a server that can't order requests itself. |
| Its limits | Two at a time below High, plus two Medium places. | Six of the tab's requests going to one server, and ten low ones in all. |
| When it lets go | When the parser reaches <body>, or a running request ends. | When a request ends, or a waiting one's priority goes up. |
| HTTP/2 and HTTP/3 | They change nothing here. | It lets everything go, unless Chrome rates the network 3G or slower. |
So when the Network panel shows a long Queueing time, ask which scheduler made it. If the page was still in its head, it was tight mode: make the head shorter. If many files went to one HTTP/1.1 server, it was the network service. Check what your server speaks, as in Connections in practice, or raise the one file that matters, as in Load the LCP resource early.
Which part of Chrome held it?
Each request below comes from a page like the Mint tea page. Sort it by what held it back, if anything:
- An async script, while a slow script in the head holds the parser
- A third Medium photo, found while the parser is still in the head and two Medium photos load
- A Low icon after
<body>, with six requests already going to its HTTP/1.1 server - A Low icon over HTTP/2 on a network Chrome rates 3G, while eight other low requests load
- The stylesheet in the head
- A
fetch()for prices, made by the slow script in the head - A photo with
fetchpriority="high", found while the parser is still in the head - A Low icon over HTTP/2 on a fast network, after
<body>
Sort each request by the scheduler that held it, or by nothing.
Common mix-ups
- "The page's renderer opens its own connections." No. Only the network service talks to the network. It has a process of its own on most platforms, and a thread in the browser process on Android.
- "Over HTTP/2, Chrome sends every request at once." No. Tight mode still holds requests in the renderer until
<body>. And on a network Chrome rates 3G or slower, the network service holds low ones too. - "Chrome never has more than six requests going to one server." No. Over HTTP/1.1, six connections set that limit. Over HTTP/2, the recorded visit had thirteen requests going to one server at once.
- "Layout can lower an image's priority." No. The update after layout only ever raises a priority, and it skips images that have already arrived.
- "The preload scanner fetches lazy images early, at a low priority." No. It makes no request for an
<img loading="lazy">at all. - "DevTools' Medium is the network's MEDIUM." No. The network's
MEDIUMis DevTools' High. DevTools' Medium is the network'sLOW.
Practice exercises
Answer first, then use the hints.
shop.css and mint.jpg have finished, so only menu.js and black.jpg are running. What does the first line print?
// A small model of the renderer's tight-mode check, written for this lesson.
function mayStart(priority, running) {
if (priority === "High" || priority === "Highest") return true;
const medium = running.filter((p) => p === "Medium").length;
if (priority === "Medium" && medium < 2) return true;
return running.length < 2;
}
const running = ["High", "Medium"]; // menu.js, black.jpg
console.log(`chamomile.jpg: ${mayStart("Medium", running) ? "starts" : "waits"}`);
console.log(`card.svg: ${mayStart("Low", running) ? "starts" : "waits"}`);chamomile.jpg: starts. One Medium place is free, so a Medium request may start, even though two requests are running.
This time only three requests are going to the server. What does it print?
// A small model of the network service's check, written for this lesson.
function mayStart(priority, goingToThisServer, server) {
if (priority === "High" || priority === "Highest") return true;
if (server === "HTTP/2") return true;
return goingToThisServer < 6;
}
console.log(`bank.svg over HTTP/1.1: ${mayStart("Low", 3, "HTTP/1.1") ? "starts" : "waits"}`);bank.svg over HTTP/1.1: starts. Below High on HTTP/1.1, a request starts while fewer than six are going to its server.
On the HTTP/1.1 visit, when did the network service let points.svg go, in ms?
At 1,257 ms. It was the last of the six icons, let go when rooibos.jpg and card.svg finished.
reviews.js is a script, yet it started at Low. Which line of resource_fetcher.cc lowered it?
Line 635. The scanner marks an async script to load lazily, and ComputeLoadPriority drops it to Low there.
Open the course's copy of the Mint tea page with DevTools' Network panel open, and reload. What does the Initiator column show for card.svg?
page.html:29. The scanner noted where card.svg's tag is, and DevTools shows that line of the page.
A shop's LCP photo is the seventh large image on its page. The head has a slow script, and the server speaks HTTP/1.1. Which one attribute on the photo's tag gets it past both schedulers?
fetchpriority="high". The photo starts at High, so tight mode lets it through, and the network service doesn't count it as delayable.
Check your understanding
For each question, ask where the request was: in the scanner, in the fetcher, in the renderer's queue, or in the network service.
Question 1 of 8What does the second line of the tight-mode model print?
Read the code, then predict// A small model of the renderer's tight-mode check, written for this lesson. function mayStart(priority, running) { if (priority === "High" || priority === "Highest") return true; const medium = running.filter((p) => p === "Medium").length; if (priority === "Medium" && medium < 2) return true; return running.length < 2; } const running = ["Highest", "High", "Medium", "Medium"]; // shop.css, menu.js, mint.jpg, black.jpg console.log(`chamomile.jpg: ${mayStart("Medium", running) ? "starts" : "waits"}`); console.log(`card.svg: ${mayStart("Low", running) ? "starts" : "waits"}`);Choose an answer to see the explanation.
Question 2 of 8In the recordings, why did card.svg wait in the network service over HTTP/1.1, but not over HTTP/2?
Choose an answer to see the explanation.
Question 3 of 8What ends tight mode in the renderer?
Choose an answer to see the explanation.
Question 4 of 8Where does Chrome's network service run on Android?
Choose an answer to see the explanation.
Question 5 of 8DevTools shows a request at High. What does the network service call that priority?
Choose an answer to see the explanation.
Question 6 of 8After layout, most of the recorded teas went up to High. Why did mint.jpg stay at Medium?
Choose an answer to see the explanation.
Question 7 of 8What does Chrome's preload scanner do with <img loading="lazy">?
Choose an answer to see the explanation.
Question 8 of 8Does HTTP/2 stop the network service from holding requests on a network Chrome rates 3G?
Choose an answer to see the explanation.
Key takeaways
- The preload scanner reads the HTML again with its own tokenizer: the first piece at once, later pieces while the parser waits.
ComputeLoadPrioritypicks the priority: the kind of file, then async,fetchpriorityand the first five large images. After layout, images on the screen can only go up.- The network service sends every request. It runs in a process of its own on most platforms, and on a thread on Android.
- A request below High can wait twice: in the renderer until
<body>, and in the network service when its server can't order requests. - HTTP/2 and HTTP/3 end the second wait on fast networks, but not on networks Chrome rates 3G or slower.
Remember the one-liner.
Found by the scanner, labelled by the fetcher, then held, maybe twice: by the renderer until <body>, and by the network service.
Sources
The facts on this page come from Chromium's own source and docs, at the release the course records with, and these standards:
- html_document_parser.cc: when the preload scanner runs, Chromium source, 157.0.8103.52.
- html_preload_scanner.cc: what the preload scanner reads, Chromium source, 157.0.8103.52.
- Request Prioritization, in platform/loader/fetch/README.md, Chromium docs, 157.0.8103.52.
- resource_fetcher.cc: TypeToPriority and ComputeLoadPriority, Chromium source, 157.0.8103.52.
- resource_request_utils.cc: fetchpriority and render-blocking, Chromium source, 157.0.8103.52.
- web_url_request.cc: Blink's priorities as the network's, Chromium source, 157.0.8103.52.
- spdy_http_utils.cc: the priority header on HTTP/2, Chromium source, 157.0.8103.52.
- Network Service, services/network/README.md, Chromium docs, 157.0.8103.52.
- url_loader.cc: URLLoader::ScheduleStart, Chromium source, 157.0.8103.52.
- resource_load_scheduler.cc: the renderer's scheduler and tight mode, Chromium source, 157.0.8103.52.
- resource_scheduler.cc: the network service's scheduler, Chromium source, 157.0.8103.52.
- resource_scheduler_params_manager.cc: limits by network quality, Chromium source, 157.0.8103.52.
- http_server_properties.cc: which servers order requests themselves, Chromium source, 157.0.8103.52.
- RFC 9218: Extensible Prioritization Scheme for HTTP, IETF.
- Providing network details for bug reports (chrome://net-export), The Chromium Projects.
Coming next: Inside the rendering engine. Once the files have arrived, Chrome turns them into pixels: style, layout, paint and the compositor, read from the same source.