Performance and sustainability
Estimate a page's energy and carbon with the Sustainable Web Design model and CO2.js, and see where speed work cuts emissions and where it adds them.
- 01Estimate a page's carbonTurn the bytes a page sends into energy and grams of CO2e with the Sustainable Web Design model, and say what the model counts.
- 02Tell bytes from CPU timeSee that the model only sees bytes, while the phone also spends energy on every millisecond its processor works.
- 03Weigh speed tricks for the planetKnow which speed work also saves energy, and which tricks spend bytes and work on guesses and copies.
Is Ravi's shop green?
A customer writes to Ravi. Her name is Ana, and she loves his Mint tea. Her question is short: "Is your website green?"
Ravi doesn't know what to say. His shop has no chimney. His website burns nothing he can see. But every visit uses electricity. A data centre sends the page. A network carries it. Asha's phone shows it. And much of that electricity comes from power stations that burn coal or gas. They put carbon dioxide, or CO2, into the air.
So Ravi has two questions. How much carbon does one visit to his Mint tea page cost? And is making the page greener the same work as making it fast?
In lesson 37.2, Ravi built a lighter Mint tea page for Asha's phone. The course loaded both pages in Chrome, with the CPU slowed down to match Asha's phone. It counted every byte Ravi's server sent. Then it turned the bytes into grams with CO2.js, a library from the Green Web Foundation. Here is what Chrome drew, and what each visit cost:
The two pages look alike at the top. Here are the numbers behind them:
// Ravi's two Mint tea pages on Asha's phone, from the course's recording.// The bytes Ravi's server sent, and CO2.js's estimate in grams of CO2e.const full = { bytes: 346618, grams: 0.0514 };const light = { bytes: 15671, grams: 0.0023 }; console.log(`Full page: ${full.bytes} bytes, about ${full.grams} g`);console.log(`Lighter page: ${light.bytes} bytes, about ${light.grams} g`);console.log(`The full page sends ${Math.round(full.bytes / light.bytes)} times the bytes`);- Lines 1 and 2 are comments. CO2e means "CO2 equivalent". Other gases that warm the planet are counted as the amount of CO2 that would warm it as much.
- Lines 3 and 4 hold each page's bytes, and its estimate in grams.
- Line 6 prints
Full page: 346618 bytes, about 0.0514 g. Line 7 printsLighter page: 15671 bytes, about 0.0023 g. - Line 8 prints
The full page sends 22 times the bytes.
One visit to the full page costs about a twentieth of a gram. That sounds tiny. But a page isn't opened once. A thousand visits to the full page come to about 51 grams. A thousand visits to the lighter page come to about 2 grams.
And Ravi's full page is light for the web. The Web Almanac is HTTP Archive's yearly report on how the web is built. It used the same model on the pages HTTP Archive tests. Its middle mobile page came to 0.33 grams.
Why it matters: the change that made the page fast for Asha also made it about 22 times lighter for the planet. The rest of this lesson shows when speed and carbon go together, and when they don't.
Ravi's tea goes out in a delivery van. The van uses fuel at the depot, on the road, and at the door. A heavier load uses more. A trip to a house where nobody ordered anything uses fuel for nothing. And a customer with a full tin at home needs no trip at all.
- In real life: The load in the van
- In JavaScript: The bytes a visit sends
- In real life: The depot, the road and the doorstep
- In JavaScript: Data centres, networks and user devices
- In real life: A trip nobody ordered
- In JavaScript: A page fetched as a guess, and never opened
- In real life: A full tin already at home
- In JavaScript: Files the browser keeps in its cache
Every byte a page sends, and every millisecond a phone works on it, uses electricity. Models estimate the carbon from the bytes. Most speed work cuts both. Tricks that fetch or copy ahead of time spend more, and need weighing.
The next four sections take one question each:
- How do you turn bytes into grams?
- What does that estimate leave out?
- Which speed work is also green?
- Which speed tricks spend more?
How the course recorded it
- The browser: Chrome 157, with the CPU 4 times slower, on Asha's screen of 412 by 823 px.
- The pages: Ravi's two Mint tea pages, and the 1,000 reviews from lesson 31.3. Also the Mint tea photo as a JPEG and as an AVIF, and the tea list from lesson 33.3.
- The bytes: every byte Ravi's server sent for a visit, headers included.
- The work: Chrome's trace of the first 6 seconds of each visit.
- Several runs: each page 5 times, taking turns. The lesson quotes the middle visit.
- The grams: CO2.js 0.19.0, with the Sustainable Web Design model, version 4.
How web carbon is estimated
Nobody can put a meter on one visit. A data centre serves many sites at once. The network carries everyone's data. Asha's phone runs other apps too. So people estimate. They use a model: a fixed recipe that turns things you can count into an estimate.
One open model for websites is the Sustainable Web Design model. Several web companies built it, together with the Green Web Foundation. The Web Almanac and CO2.js both use it. This lesson uses its version 4.
The post office doesn't open your parcel to price it. It weighs it. The price per kilo comes from the whole post office: its vans, its sorting rooms and its staff, shared out over everything it carries. So two parcels of the same weight cost the same, whatever is inside.
- In real life: The parcel's weight
- In JavaScript: The bytes a visit moves
- In real life: The price per kilo
- In JavaScript: The model's kWh for each GB
- In real life: The whole post office's costs, shared out by weight
- In JavaScript: The internet's electricity, shared out by data
- In real life: Same weight, same price
- In JavaScript: Same bytes, same grams
Three parts, two kinds of energy
The model starts with the whole internet. It takes the electricity the world's data centres, networks and devices use, and divides it by all the data the internet moves. For example, the world's data centres used 290 billion kWh, while the internet moved 5.29 trillion GB. Divide one by the other, and you get 0.055 kWh for every GB.
A kWh, or kilowatt-hour, is the energy a 1,000-watt heater uses in one hour. The model splits the energy into three parts, which it calls segments:
- Data centres: the buildings full of servers that store and send the page.
- Networks: the cables, routers and mobile masts that carry it.
- User devices: the phone or laptop that shows it.
Each part has two kinds of energy. Operational energy is the electricity that runs the machines. Embodied energy went into making them. The model counts both.
Then it turns energy into carbon. The carbon intensity of electricity is how many grams of CO2e each kWh puts into the air. The model uses the world's average: 494 g for each kWh. You can use a country's own figure when you know it.
Here is the same sum in code, for the full page:
// The Sustainable Web Design model, version 4: kWh for each GB moved.const kWhPerGB = { dataCentres: 0.055 + 0.012, networks: 0.059 + 0.013, devices: 0.08 + 0.081 };const gramsPerKWh = 494; // the world's average gridconst gb = 346618 / 1e9; // Ravi's full page, in GB for (const [part, kWh] of Object.entries(kWhPerGB)) { console.log(`${part}: ${(gb * kWh * gramsPerKWh).toFixed(4)} g`);}- Line 1 is a comment.
- Line 2 holds each part's kWh per GB: its operational and its embodied energy, added up.
- Line 3 is the grid: 494 g for every kWh.
- Line 4 turns the page's 346,618 bytes into GB. Like CO2.js, it counts a GB as a billion bytes.
- Lines 6 to 8 multiply the GB by the kWh by the grams, for each part. They print
dataCentres: 0.0115 g,networks: 0.0123 ganddevices: 0.0276 g.
Add them up, and you get 0.0514 g. User devices are more than half of it. Why it matters: the phone in Asha's hand is the biggest part of the estimate. A lighter page saves energy right where the visitor is.
CO2.js does the sums for you
CO2.js is the Green Web Foundation's JavaScript library for these estimates. Its default model is this one, version 4. Here it is on the full page:
import { co2 } from "@tgwf/co2"; const model = new co2({ model: "swd", version: 4, rating: true });const ordinary = model.perByte(346618, false);const green = model.perByte(346618, true); console.log(ordinary.total.toFixed(4), ordinary.rating); // 0.0514 Aconsole.log(green.total.toFixed(4), green.rating); // 0.0420 A- Line 1 imports CO2.js. It's an npm package,
@tgwf/co2, so this example doesn't run on this page. - Line 3 picks the Sustainable Web Design model, version 4, and asks for a rating.
- Line 4 asks for the grams of 346,618 bytes. The second argument,
false, says the host isn't green. - Line 5 asks again, for a green host.
- Line 7 prints
0.0514 A. Line 8 prints0.0420 A.
A green host runs its servers on renewable or zero-carbon electricity. The Green Web Foundation has checked hosting companies for this since 2006. Anyone can search its list, the Green Web Dataset.
Look at what the green host changed: 0.0514 g became 0.042 g, about 18% less. The model only takes out the data centres' operational energy. The networks, the phones, and the making of every machine stay. Making the page lighter cut about 95% instead.
The letter is the model's rating. A+ means 0.040 g or less for a visit. F starts at the weight of the web's middle page, about 2.4 MB. Ravi's full page gets an A, and the lighter page an A+. Try the model on Ravi's visits. Pick one, and turn the green host on and off:
- Bytes sent346,618
- Data centres0.0115 g
- Networks0.0123 g
- User devices0.0276 g
- Energy, all three parts0.104 Wh
- Grams of CO2e0.0514 g
- RatingA
- 1,000 visits like this one51.4 g
The model gives each GB 0.3 kWh, shared between data centres, networks and user devices, and each kWh 494 g.
What the model counts, and what it doesn't
The model's own page is plain about its input. It uses the bytes as "a proxy metric": a stand-in for everything else. It says it won't help you estimate one part of a system, like a server's CPU. And the Web Almanac adds that JavaScript's work on memory, CPU and GPU has impacts "not yet considered in the SWD model".
There's a second way to put a number on software. The Green Software Foundation's Software Carbon Intensity, or SCI, is a rate: carbon for one unit of use, like one visit. Its formula is (E × I + M) per R:
- E is the energy the software used.
- I is the carbon intensity of that electricity.
- M is a share of the carbon from making the hardware.
- R is the unit you count per, like one visit or one user.
SCI lets you measure the energy, or model it. Buying carbon offsets doesn't lower an SCI score. Only using less energy, less hardware, or cleaner electricity does.
Why it matters: a bytes model is quick, and fair for comparing pages. But it gives the same answer for two pages that send the same bytes, however hard they make the phone work. The next section measures that work.
Bytes, CPU time, and energy
A phone spends energy on a page in two ways. Its radio receives the bytes. Its processor, the CPU, turns them into a page: it parses the HTML, runs the scripts, lays out and paints.
Android's docs show how a phone counts this. Each part of the phone has a power profile: the extra current it draws while it's busy. The CPU has one for each of its speeds. The mobile radio has one for sending and receiving. Android multiplies each current by the time that part was busy. That tells it how much battery the part drained. So a busy CPU drains the battery, just as a busy radio does.
Picture a taxi meter that only counts kilometres. It charges the same for a clear road as for an hour stuck in traffic. But in traffic, the engine runs the whole time. It burns fuel without moving.
- In real life: The kilometres on the meter
- In JavaScript: The bytes the model counts
- In real life: Time stuck in traffic, engine running
- In JavaScript: Time the phone's CPU is busy
- In real life: The fuel the engine really burns
- In JavaScript: The energy the phone really uses
The course read both from each visit: the bytes from Ravi's server, and the main thread's busy time from Chrome's trace. The main thread is the thread that parses the HTML, runs the page's JavaScript, and does layout and paint, as lesson 6.1 showed.
// Four pages on Asha's phone: CO2.js's grams, and the main thread's busy time.const pages = [ { name: "Full page", grams: 0.0514, mainMs: 159.8 }, { name: "Lighter page", grams: 0.0023, mainMs: 79 }, { name: "1,000 reviews", grams: 0.0626, mainMs: 234.5 }, { name: "With content-visibility", grams: 0.0626, mainMs: 138.9 },];for (const page of pages) { console.log(`${page.name}: ${page.grams} g, main thread ${page.mainMs} ms`);}- Line 1 is a comment.
- Lines 3 to 6 hold four pages: the grams CO2.js gave each, and how long the main thread was busy in the first 6 seconds.
- Lines 8 to 10 print one line per page. First
Full page: 0.0514 g, main thread 159.8 msandLighter page: 0.0023 g, main thread 79 ms. - Then
1,000 reviews: 0.0626 g, main thread 234.5 msandWith content-visibility: 0.0626 g, main thread 138.9 ms.
Look at the Mint tea pages first. The full page sent 22 times the bytes. But its main thread worked only about twice as long. Both costs fell with the lighter page, by very different amounts.
Now the reviews. In lesson 31.3, Ravi gave each review content-visibility: auto. It lets Chrome skip laying out and painting a review until it comes near the screen. Both pages send about 422,000 bytes, so CO2.js gives both 0.0626 g. But the main thread worked 96 ms less. Layout alone fell from 127 ms to 51 ms.
Why it matters: bytes and CPU time are two different costs. A bytes model can't see the second one. So measure both: the bytes for the estimate, and the main thread for the work on the phone.
Compare the two pairs yourself. The lab also shows every thread of the page's renderer together: the main thread, and the helpers that decode images and draw.
- Bytes sent346,618 → 15,671
- CO2.js's estimate0.0514 g → 0.0023 g
- Main thread busy160 ms → 79 ms
- All the renderer's threads busy223 ms → 95 ms
- Image decoding6.1 ms → 1.6 ms
Fewer bytes and less work: the lighter page has no font, no video and no reviews until Asha asks.
Where performance and sustainability agree
Most of the speed work in this course also cuts energy. Three kinds stand out:
- Fewer bytes. The lighter page sent 15,671 bytes instead of 346,618. On long waits, Asha's photo showed sooner (lesson 37.3). And the estimate fell by about 95%.
- Less JavaScript. Every script is bytes to send, and work to parse and run. Lesson 22.1 showed how much is too much.
- Caching. A file the phone already has costs nothing to send.
The first time you buy Ravi's mint tea, you walk to the shop. After that, the tin sits in your kitchen. Each new cup only needs fresh water. It's quicker for you, and nobody drives another tin to your door.
- In real life: The first walk to the shop
- In JavaScript: The first visit, which downloads every file
- In real life: The tin in your kitchen
- In JavaScript: Files in the browser's HTTP cache
- In real life: Fresh water for each cup
- In JavaScript: The page itself, which the browser may not keep
- In real life: No delivery van needed
- In JavaScript: No bytes sent, and no energy to send them
Ravi's server lets every file but the page itself be cached for a year, as lesson 15.1 taught. The course opened the full page twice in the same browser:
// The full page twice in the same browser. The second visit finds the first one's files.const first = { bytes: 346618, mainMs: 159.8 };const second = { bytes: 160032, mainMs: 125.9 };const sentAgain = ["the page", "the brewing video"]; console.log(`Second visit: ${Math.round((second.bytes / first.bytes) * 100)}% of the bytes`);console.log(`Main thread: ${second.mainMs} ms instead of ${first.mainMs} ms`);console.log(`Sent again: ${sentAgain.join(" and ")}`);- Line 1 is a comment.
- Lines 2 and 3 hold each visit's bytes and the main thread's busy time.
- Line 4 lists what Ravi's server sent the second time.
- Line 6 prints
Second visit: 46% of the bytes. Line 7 printsMain thread: 125.9 ms instead of 159.8 ms. - Line 8 prints
Sent again: the page and the brewing video.
The cache kept the photo, the script, the font and the reviews. The estimate fell from 0.0514 g to 0.0237 g. But the brewing video came again, every byte of it, on every second visit the course made. Only checking the second visit showed that.
The Web Sustainability Guidelines, or WSG, are advice from a W3C group, the Sustainable Web Interest Group. Its guideline 4.2 asks for exactly that check: "verify caching behavior using both initial and repeat visits". Its guideline 2.9 asks for autoplay to be off by default. The lighter page does that too: its video waits behind a button.
The model knows about caching as well. Its full formula has a share of returning visitors, and a share of the data they get from their cache. Why it matters: a cache makes the second visit faster and lighter at once. Check the second visit in DevTools, and look for files that still come every time.
WSG goes one step further. Its guideline 5.24 asks teams to cap a page's size with performance budgets, for speed and for the planet. That's where the next stage of this course starts. Until then, compare the two kinds of saving:
- Bytes sent346,618 → 160,032
- CO2.js's estimate0.0514 g → 0.0237 g
- Main thread busy160 ms → 126 ms
- All the renderer's threads busy223 ms → 186 ms
- Image decoding6.1 ms → 4 ms
The cache kept the photo, the script, the font and the reviews. The page and the brewing video came again.
Where performance and sustainability disagree
Some speed tricks make a page feel faster by doing more. They fetch, keep or work ahead of time. The visitor waits less, but somebody spends more bytes or more work. WSG warns about this: a gain in one area can cost something in another.
A busy café cooks its most popular dishes before the doors open. A customer who orders one gets it at once. But a customer who only wants a glass of water leaves, and the dishes go in the bin.
- In real life: Cooking before anyone orders
- In JavaScript: Prefetching or prerendering pages before a tap
- In real life: The dish served at once
- In JavaScript: The page that opens at once
- In real life: Dishes in the bin
- In JavaScript: Bytes for pages nobody opened
- In real life: The gas and the ingredients
- In JavaScript: Bandwidth, memory and CPU
Guesses that nobody opened
In lesson 33.3, Ravi's viewport script prefetched every tea link on Asha's screen. A prefetch fetches a page's HTML before the tap. This time, Asha read the list for 6 seconds and left:
// Asha reads the tea list and leaves without tapping.const prefetched = ["mint-tea", "green-tea", "chamomile", "black-tea", "jasmine", "oolong", "rooibos"];const guessBytes = 9789;const grams = 0.0015; console.log(`${prefetched.length} pages fetched, 0 opened`);console.log(`${guessBytes} bytes for nothing, about ${grams} g`);- Line 1 is a comment.
- Line 2 lists the pages Chrome prefetched. 7 teas were on Asha's screen.
- Lines 3 and 4 hold their bytes, and CO2.js's grams for them.
- Line 6 prints
7 pages fetched, 0 opened. Line 7 prints9789 bytes for nothing, about 0.0015 g.
Prefetches are small: Ravi's tea pages are about 1.4 KB each. A prerender isn't. It loads the whole page in a hidden tab: its photo, its styles and its layout. In lesson 33.3, the prerendering script fetched 450,890 bytes before Asha's tap. 346,917 of them were for teas she never opened.
CO2.js puts those wasted bytes at 0.0514 g. That's as much as a whole visit to the full Mint tea page. In return, the photo appeared 47.8 ms after the tap, instead of 301.1 ms.
Chrome's docs warn that over-speculation "has a clear cost to users for bandwidth, memory, and CPU". Chrome holds speculation back when a visitor saves data, and when Energy saver is on and the battery is low. Why it matters: a guess is worth it when it's likely to be used. Guess from data, as lesson 33.3 did, and let visitors who save data skip the guessing.
Smaller files, more unpacking
A newer image format can hold the same photo in fewer bytes, as lesson 18.1 showed. But before Chrome can draw a photo, it has to unpack it into pixels. That work is called decoding, and a smaller file can need more of it. The course saved the Mint tea photo twice, at the same quality score, as lesson 18.1 did:
// The Mint tea photo, saved twice at the same quality score. Middle of 5 loads each.const jpeg = { bytes: 70487, decodeMs: 8.4 };const avif = { bytes: 49162, decodeMs: 9.1 }; const saved = Math.round((1 - avif.bytes / jpeg.bytes) * 100);console.log(`AVIF: ${saved}% fewer bytes`);console.log(`AVIF: ${(avif.decodeMs - jpeg.decodeMs).toFixed(1)} ms more decoding`);- Line 1 is a comment.
- Lines 2 and 3 hold each file's bytes, and the middle decode time of 5 visits, from Chrome's trace.
- Line 5 works out the share of bytes the AVIF saved.
- Line 6 prints
AVIF: 30% fewer bytes. Line 7 printsAVIF: 0.7 ms more decoding.
Decoding the AVIF took longer in 4 of the 5 rounds. Chrome did it on its worker threads, so the main thread stayed free. Here the choice is easy: 21,325 fewer bytes, for less than a millisecond of extra work.
WSG's guideline 4.3 asks you to compress responses and media "while balancing processing costs". Why it matters: the model counts the bytes you save, but not the decoding you add. On a page with many large images, measure both.
Copies close to every visitor
A CDN, from lesson 15.4, keeps copies of a site's files in many places. MDN calls it "a group of servers spread out over many locations" that "store duplicate copies of data". Each visitor gets a nearby copy, so the bytes arrive sooner.
But each copy is stored on another server. The bytes model can't see that. It counts the bytes a visit moves, not how many copies wait around the world. WSG's guideline 4.10 asks you to weigh a CDN's speed against its impact, case by case. When every visitor lives nearby, it suggests hosting close to them instead.
Why it matters: a CDN pays off when visitors are far from the server. When they're all nearby, a close server is fast and needs no copies. Compare the photo formats and the guesses here:
- Bytes sent73,128 → 51,804
- CO2.js's estimate0.0108 g → 0.0077 g
- Main thread busy69 ms → 71 ms
- All the renderer's threads busy90 ms → 89 ms
- Image decoding8.4 ms → 9.1 ms
The AVIF page sent fewer bytes. Decoding the photo took a little longer, on Chrome's worker threads.
Faster, greener, or both?
Here is every change from this lesson in one table. Read each row across: what the change did to the bytes, to the work on the phone, and to speed.
| The change | Bytes sent | Work on the phone | Speed |
|---|---|---|---|
| The lighter page | 346,618 down to 15,671. | Main thread 160 ms down to 79 ms. | The photo showed sooner on long waits (lesson 37.3). |
content-visibility: auto on 1,000 reviews | The same: 422,217 and 422,303. | Main thread 235 ms down to 139 ms. | The first frame came sooner (lesson 31.3). |
| A second visit, with the cache | 346,618 down to 160,032. | Main thread 160 ms down to 126 ms. | Less to download, so less to wait for. |
| The photo as AVIF, not JPEG | 70,487 down to 49,162. | Decoding 8.4 ms up to 9.1 ms. | Less to download. |
| Prefetching every tea on screen | 9,789 more, for pages nobody opened. | Main thread 71 ms up to 79 ms. | Faster only after a tap (lesson 33.3). |
| Prerendering every tea on screen (lesson 33.3) | 450,890 before the tap. | Each guessed page loads in a hidden tab. | The photo 47.8 ms after the tap, not 301.1 ms. |
Now sort these changes. Does each one make the page faster and lighter, or faster but more costly?
- Sending the lighter Mint tea page to phones that ask to save data
- Letting the photo, script and font be cached for a year
- Removing a script nobody uses
content-visibility: autoon 1,000 reviews- A Play button instead of a video that plays by itself
- Prefetching every tea link on the screen
- Prerendering every tea link on the screen
- Copies of every file on a worldwide CDN, for a shop whose buyers all live in one town
Sort each change by whether it saves energy as well as time.
Common mix-ups
- "A page's carbon can be measured exactly." No. Models estimate it. The Sustainable Web Design model shares out the whole internet's electricity by bytes.
- "A green host makes a page carbon-free." No. It only takes out the data centres' operational part. The full page went from 0.0514 g to 0.042 g.
- "The same bytes means the same work." No. Both reviews pages sent about 422,000 bytes. One kept the main thread busy for 235 ms, the other for 139 ms.
- "Fewer bytes always means less work on the phone." No. The AVIF was 21,325 bytes smaller, and took a little longer to decode.
- "Every speed trick is also green." No. Prefetching and prerendering spend bytes on pages that may never open.
- "The device part is small." No. In the model, user devices are more than half of each GB's energy.
Practice exercises
Answer first, then use the hints.
Ravi's friend has a 1 MB page. What does this print?
// The model's energy for each GB: all three parts, using and making.
const kWhPerGB = 0.3;
const gramsPerKWh = 494;
const bytes = 1000000; // a 1 MB page
console.log((bytes / 1e9 * kWhPerGB * gramsPerKWh).toFixed(3));0.148. A 1 MB page is 0.001 GB. The model gives it 0.0003 kWh, and 0.0003 kWh at 494 g per kWh is 0.1482 g.
What rating does the model give the Web Almanac's middle mobile page?
const ratings = [["A+", 0.04], ["A", 0.079], ["B", 0.145], ["C", 0.209], ["D", 0.278], ["E", 0.359]];
const ratingOf = (grams) => ratings.find(([, upTo]) => grams <= upTo)?.[0] ?? "F";
// The middle mobile page in the Web Almanac, with the same model.
console.log(ratingOf(0.33));E. The web's middle mobile page is just under F, which starts at the middle page's weight.
Ravi moves the 1,000 reviews page to a green host. How many grams does the model give one visit?
0.0511 g, down from 0.0626 g. The green host takes out the data centres' operational part, and nothing else.
How long were all the full page's renderer threads busy together, in ms?
223 ms, against 160 ms for the main thread alone. The other threads decode images, draw, and play the brewing video.
Open lesson 37.3's copy of the lighter page in Chrome, with DevTools' Network panel open. Tap Play the brewing video. Which file does the tap download?
brew.mp4. The lighter page only fetches the video when someone asks for it. Visitors who don't want it never pay for its bytes, or for the energy to send them.
The model's default grid figure is 494 g of CO2e per kWh. Whose data does it come from?
Ember. The model takes the world's average carbon intensity of electricity, 494 g per kWh, from Ember's Data Explorer.
Check your understanding
For each question, ask: what did the change do to the bytes, and what did it do to the work on the phone?
Question 1 of 7With the model's 0.3 kWh per GB and 494 g per kWh, what does this print for a 2,000,000-byte page?
Read the code, then predictconst kWhPerGB = 0.3; // all three parts, using and making const gramsPerKWh = 494; console.log((2000000 / 1e9 * kWhPerGB * gramsPerKWh).toFixed(3));Choose an answer to see the explanation.
Question 2 of 7What does the Sustainable Web Design model need to estimate one visit?
Choose an answer to see the explanation.
Question 3 of 7Ravi moves his shop to a host the Green Web Foundation lists as green. What does CO2.js take out of the estimate?
Choose an answer to see the explanation.
Question 4 of 7Two versions of the reviews page send the same bytes. One uses content-visibility: auto. What did the recording show?
Choose an answer to see the explanation.
Question 5 of 7Asha reads Ravi's tea list and leaves without tapping. What happened to the pages the viewport script prefetched?
Choose an answer to see the explanation.
Question 6 of 7Why does Chrome stop speculative loading when Energy saver is on and the battery is low?
Choose an answer to see the explanation.
Question 7 of 7In the Sustainable Web Design model, which segment gets the most energy for each GB?
Choose an answer to see the explanation.
Key takeaways
- Web carbon is estimated, not measured. The Sustainable Web Design model gives each GB 0.3 kWh, and each kWh 494 g of CO2e.
- The model splits the energy between data centres, networks and user devices. User devices are more than half.
- A green host only takes out the data centres' operational part. Ravi's lighter page cut far more.
- The model sees bytes, not CPU time. Two pages with the same bytes made the main thread work 235 ms and 139 ms.
- Fewer bytes, less JavaScript and caching make a page faster and lighter at once.
- Prefetching and prerendering spend bytes and work on guesses. Smaller formats can cost decoding, and CDNs keep copies in many places.
Remember the one-liner.
Every byte and every busy millisecond uses energy; most speed work saves both, but guesses and copies spend some to save time.
Looking back at this stage
This is the last lesson of Stage 12, Devices, networks, and people. Here is what the stage covered:
- Testing on low-end devices: a real phone shows what throttling can't.
- Adaptive loading: send a lighter page to phones and networks that need one.
- Slow and unreliable networks: time limits, retries, and a copy of the shop on the phone.
- Webviews, in-app browsers, and PWAs: the same page starts differently in each place.
- Performance and accessibility: speed tricks must keep everyone's place.
- Performance and sustainability: every byte and every busy millisecond uses energy.
Sources
The facts on this page come from these models, specs, docs and data:
- Estimating Digital Emissions: the Sustainable Web Design Model, version 4, Sustainable Web Design.
- Digital Carbon Ratings, Sustainable Web Design.
- CO2.js: Models, Green Web Foundation.
- @tgwf/co2 (CO2.js) on npm, Green Web Foundation.
- Green Web Dataset, Green Web Foundation.
- Web Almanac: Sustainability, HTTP Archive.
- Software Carbon Intensity (SCI) Specification, Green Software Foundation.
- Measure power values, Android Open Source Project.
- Web Sustainability Guidelines (WSG), W3C Sustainable Web Interest Group.
- Prerender pages in Chrome for instant page navigations, Chrome for Developers.
- CDN, MDN.
Coming next: Performance budgets. Stage 13, Performance as a practice, starts there: how to set limits on bytes, requests and timings, choose them from data, and keep a page inside them.