Loading

T3 Browser DevTools · Lesson 6

Performance and Lighthouse

What fast means: LCP, INP and CLS; recording a page in the Performance panel and reading its flame chart; the main thread, long tasks and forced layouts; a full review with Lighthouse; and the rule of timing first.

  • explain LCP, INP and CLS, with their targets
  • record a page, and read what the Performance panel shows
  • explain the main thread and long tasks, and why a click can feel slow
  • run Lighthouse, and decide what to do first from its report
  • find a real cause by timing, and avoid fixing what is not slow
About 60 minutesChecked against Google Chrome on the laptop (the kit renders every HTML block in it, and the DevTools step describes its panels) 155 (2026-11-06)Play this lesson's games

The back cover

A page can be correct and still feel broken, because it arrives late, ignores a tap or jumps under your thumb. Speed is not one number, and guessing at it wastes days. The browser can measure exactly what the visitor felt.

These pages explain the three numbers of a fast page: LCP, INP and CLS. They show how to record a page in the Performance panel and read its flame chart, and why one busy main thread freezes everything. They run a full Lighthouse review and show how far to trust it. They end with the rule of all speed work: time it first.

Before you start

The story: The board that sighed

Nothing is broken on the Exchange's price board, and the merchants hate it. It takes an age to wake. Its figures jump down the glass as the pictures arrive, so that a trader taps the wrong line. And when a trader does tap, the board sighs for a long moment before it answers. All five lenses show nothing wrong.

Corin is sure that the pictures are to blame, and starts to shrink them. Ottilie Sen stops his hand, and sets a sixth lens on the bench, with a tiny clock in its rim.

"Broken is easy," she says. "Slow is hard, because it is made of small things that each look innocent. Time it first. Then you will know what to touch."

A page that does the right thing slowly still loses its visitors. This lesson moves from "does it work?" to "how does it feel?". It gives you three numbers that say what a visitor feels, a panel that shows where the time goes, and a tool that reviews a whole page. It builds on these ideas; each has a tiny example.

What you already knowA tiny exampleWhere it comes back
A page makes many requests.The Network panel's Waterfall.Loading speed is one part of the story.
A browser has three jobs for each picture.Layout, paint, composite.This panel shows each job as a bar.
About 60 pictures a second looks smooth.1000 ÷ 60 is about 16.7 milliseconds.A long job misses that deadline.
Scripts run one line at a time.A loop runs to its end.While it runs, nothing else can.
Reading a size can force a layout.element.offsetHeightDoing so in a loop is a common cause of slowness.
Images have a width and a height.<img width="800" height="300">They let the browser keep a place.
Throttling makes a slow connection.Slow 4G in the Network panel.A slow CPU can be made the same way.
Measure, do not guess.The kit measures each claim.You will do the same.

By the end of this lesson you will be able to:

  • explain LCP, INP and CLS, with their targets;
  • record a page in the Performance panel, and read what it shows;
  • explain the main thread and long tasks, and why a click can feel slow;
  • run Lighthouse, and decide what to do first from its report;
  • find a real cause by timing, and avoid fixing what is not slow.

How to follow this lesson

The numbers under the blocks are from Chrome itself: the kit served each page from a small server and asked Chrome to measure it, with a short script of its own that is not shown. Your own numbers will differ a little, as speed depends on the machine. Most blocks here can be run on this page. Open the Performance panel first, press Run, and read the live figures.

In one line

Speed is what a visitor feels; this lesson gives you the numbers for it and the panels that find the cause, and it builds on the Network panel and on layout, paint and composite.

What fast means: three numbers

At a glance

A visitor does not feel speed as one thing. They feel three moments: when the page seems to arrive, whether it answers when touched, and whether it keeps still. Each moment has a number, and together the three are called the Core Web Vitals.

LCP, Largest Contentful Paint, says when the main content appeared; good is 2.5 seconds or less. INP, Interaction to Next Paint, says how quickly the page answers; good is 200 milliseconds. CLS, Cumulative Layout Shift, says how much things jump; good is 0.1 or less. Late content that is given its space in advance does not push anything.

Take a guess: Which of the three numbers grows when an image without a size pushes text down?

A visitor does not experience "speed". They experience three moments: when the page seems to arrive, whether it answers when touched, and whether it keeps still. Each has a number, and together these are called the Core Web Vitals.

NumberStands forIt asksGood is
LCPLargest Contentful Paintwhen did the main content appear?2.5 seconds or less
INPInteraction to Next Painthow quickly does the page answer a touch?200 milliseconds or less
CLSCumulative Layout Shifthow much does it jump about?0.1 or less

A memory aid

Is it here? Does it answer? Does it keep still? LCP, INP, CLS.

Open the Performance panel on any page, and these numbers are there at once, in three cards, each marked good, needs improvement or poor. INP needs you to click something first. They update as you use the page.

LCP: when the main thing appears

The browser notes each larger piece of content as it paints it, and the last one before you touch the page is the largest contentful paint. It is usually a main image or a big block of text.

<!DOCTYPE html>
<style>
  body { margin: 0; }
  #main { font-size: 40px; }
</style>
<h1 style="font-size: 16px">Asha Stores</h1>
<p id="main"></p>
<script>
  setTimeout(function () {
    document.querySelector("#main").textContent = "Fresh vegetables, delivered in Pune every morning.";
  }, 500);
</script>

Chrome measured

Largest paint: a P, at about 500 ms

The heading painted at once, but it is small. The paragraph came half a second later, and it is larger, so it is the LCP. This is why a page that loads everything by script often has a slow LCP, however quick its first bytes.

CLS: when things jump

You go to tap a button, an advertisement loads above it, and everything moves down, so you tap the wrong thing. That is a layout shift. The score multiplies two fractions: how much of the window was affected, and how far things moved.

FractionMeans
impact fractionthe share of the window covered by what moved, before and after
distance fractionhow far it moved, as a share of the window's larger side

Worked example 1

In a window 800 by 600, a 200 pixel tall block moves down 100 pixels when a banner loads above it. Work out the layout shift score, then stop the shift.

What we have: a window 800 by 600, a block 200 tall, a move of 100

What we need: the score, and a fix

The plan: impact fraction times distance fraction; then keep the banner's space from the start

  1. Before and after, the block covers 300 pixels of height: 200 + 100. Of 600, that is 0.5, the impact fraction.
  2. It moved 100, and the window's larger side is 800: 100 ÷ 800 = 0.125, the distance fraction.
  3. The score is 0.5 × 0.125 = 0.0625.

The banner arrives late

<!DOCTYPE html>
<style>
  body { margin: 0; }
  p { height: 200px; margin: 0; }
</style>
<div id="sale"></div>
<p>Today's prices</p>
<script>
  setTimeout(function () {
    document.querySelector("#sale").innerHTML = "<div style='height: 100px'>Sale</div>";
  }, 300);
</script>

Chrome measured

Layout shift score: 0.0625
  • Now give the slot its height from the start, so that nothing moves when the banner arrives.
  • The space is kept

    <!DOCTYPE html>
    <style>
      body { margin: 0; }
      p { height: 200px; margin: 0; }
    </style>
    <div id="sale" style="min-height: 100px"></div>
    <p>Today's prices</p>
    <script>
      setTimeout(function () {
        document.querySelector("#sale").innerHTML = "<div style='height: 100px'>Sale</div>";
      }, 300);
    </script>

    Chrome measured

    Layout shift score: 0.0000

    0.0625, and 0 with min-height: 100px on the slot.

    Check: Chrome measured exactly 0.0625 before the fix, and 0 after it.

    Images that make room

    An image with no size takes no space until it arrives. The text below it then jumps. With width and height in the HTML, the browser works out the shape in advance, and keeps the place.

    Worked example 2

    A shop's banner image arrives a moment after the page, and the text under it jumps. Stop it, without changing the picture.

    What we have: an image that arrives late, with no size in the HTML

    What we need: a page that keeps still

    The plan: give the image its width and height, so that the browser keeps its place

    1. Without a size, the image's box is empty until it arrives, and the text sits high.
    2. When it arrives, the text is pushed down, and that is a layout shift.

    No size in the HTML

    <!DOCTYPE html>
    <style>
      body { margin: 0; }
    </style>
    <img src="hero.svg" alt="Today's offers">
    <p>Fresh vegetables</p>

    Chrome measured

    Layout shift score: about 0.02

    With a size

    <!DOCTYPE html>
    <style>
      body { margin: 0; }
      img { max-width: 100%; height: auto; }
    </style>
    <img src="hero.svg" alt="Today's offers" width="800" height="300">
    <p>Fresh vegetables</p>

    Chrome measured

    Layout shift score: 0.0000

    Add width and height. The CSS from the responsive design lesson keeps it fluid, and the place is kept.

    Check: Chrome measured a shift without the size, and 0 with it.

    Your numbers, and your visitors' numbers

    What you measure on your laptop is lab data. What real visitors get is field data, and it is the one that matters. Their phones are slower, and their networks are worse. The targets above are meant to hold for three visitors in four, on phones. The Performance panel can show field data from Chrome's public report beside your own, if the site has enough visitors.

    When you are stuck: the three numbers

    CLS is high: tick Layout Shift Regions in the Rendering tab, and reload; what moved flashes purple.

    LCP is slow: which element is it? The LCP card names it.

    INP shows no number: it needs a click or a key press first.

    Your turn

    Which number measures how quickly a page answers a tap?Tap to reveal
    1. Interaction.

    INP: 200 milliseconds or less is good.

    What is a good CLS?Tap to reveal
    1. A small fraction.

    0.1 or less.

    How do you stop an image from pushing text down when it arrives?Tap to reveal
    1. Two attributes.

    Give it width and height.

    Did you know?

    The newest of the three

    INP is the newest of the three numbers. In March 2024, web.dev announced that Interaction to Next Paint was now a stable Core Web Vital, replacing First Input Delay. Chrome then deprecated FID, and gave developers until 9 September 2024 to move over to INP. So older articles that list FID describe the web before that change.

    Why it fits here: It explains why this topic's three numbers are LCP, INP and CLS, while some older pages still list FID.

    Source: web.dev: Interaction to Next Paint is now a Core Web Vital

    Good for three visits in four

    A page does not pass by being fast once. Google's guidance is to measure the 75th percentile of page loads, separately for mobile and desktop devices. So an LCP of 2.5 seconds counts as good only if at least three loads in four show the main content within that time. The same rule applies to INP and CLS.

    Why it fits here: It is why this topic tests under a phone's conditions: a page must be good for most visitors, not only on your laptop.

    Source: web.dev: Web Vitals

    In one line

    LCP says when the main content appeared, INP how quickly the page answers, and CLS how much it jumps. Good is 2.5 seconds, 200 milliseconds and 0.1. Give late content its space in advance.

    Recording what happened

    At a glance

    The three numbers tell you that something is slow; to find out what, record. A cricket coach films a batter's stroke, because the eye cannot see it at full speed, then steps through the film. The Performance panel films the browser.

    Record a few seconds with a CPU slowdown on, like a cheaper phone. In the flame chart, a wide bar means slow, and a stack means one thing caused the next. Purple bars are layout, and a red corner marks a problem. A script's colour means nothing at all.

    Take a guess: In a flame chart, does a wider bar mean slower, or called more often?

    The three numbers tell you that something is slow. To find out what, record. A cricket coach films a batter's stroke, because the eye cannot see it at full speed, then steps through the film. The Performance panel films the browser.

    To do thisDo this
    record what happens as you use the pageclick Record, use the page, click Stop
    record a page loadclick the Record and reload button
    behave like a phonein the panel's settings, choose a CPU slowdown such as 4x, and a Network speed
    see pictures of each momenttick Screenshots

    Keep each recording to a few seconds, as there is a lot to read. And set the CPU slowdown before you start: a laptop is many times quicker than a low-priced phone. Chrome's own guide suggests 20x for a low-end phone.

    Reading a recording

    PartWhat it shows
    the overview, along the topthe whole recording: CPU use, frames, network, and screenshots if ticked
    Networkeach request, as a bar
    Frameseach picture drawn: green ones were in time
    Mainthe flame chart: everything the main thread did
    the Summary tab, belowfor what is selected: its details, or the time spent in Loading, Scripting, Rendering and Painting
    Bottom-up and Call treethe same work as lists, sorted by which function took longest

    The flame chart

    Time runs from left to right, and each bar is a piece of work. A wider bar took longer. Bars stacked on top of each other show who called whom: the upper one caused those beneath it.

    The panel gives each script's functions a colour at random, only to make the chart easier to read, so a colour there does not mean a kind of work. Layout bars are purple. A red triangle in the corner of a bar is a warning. On a Task it means a long task, and the part past 50 milliseconds is shaded red. On a Layout bar it often means a forced layout, with a link to the line that caused it.

    To do thisDo this
    zoom indrag across the overview, or press W with the chart in focus
    zoom outpress S
    move left or rightpress A or D
    learn about a barclick it, and read the Summary tab
    go to the codeclick the file link in the Summary tab
    find the worst functionopen Bottom-up, and sort by Self Time

    A memory aid

    Wide is slow, and stacked means caused. A red corner means: look here.

    The Rendering tab

    Press Ctrl + Shift + P and type Rendering to open a tab with switches that paint information onto the page itself, with no recording.

    SwitchWhat it shows
    Paint flashingareas being repainted flash green
    Layout Shift Regionswhatever shifts flashes purple
    Frame Rendering Statslive frames per second
    Scrolling performance issuesparts of the page that make scrolling slow

    If the whole screen flashes green when one small thing changes, the browser is doing far more work than it should.

    When you are stuck: recordings

    A recording is too much to read: drag across the overview to select the slow moment; everything else follows the selection.

    It looks fine on your laptop: set a CPU slowdown, and record again.

    You cannot find your code: open Bottom-up, and look for your own file names.

    Your turn

    In the flame chart, what does a wider bar mean?Tap to reveal
    1. Time runs left to right.

    It took longer.

    What does a red triangle on a Task mean?Tap to reveal
    1. A warning.

    It was a long task.

    Which button records a page load?Tap to reveal
    1. It also reloads.

    Record and reload.

    Did you know?

    Flame charts and flame graphs

    The flame chart has a cousin. Brendan Gregg invented flame graphs while working on a MySQL performance problem, to understand CPU usage quickly and in depth. Flame charts, inspired by them, were first added by Chrome's WebKit Web Inspector, and they put the passage of time on the x-axis instead of the alphabet. That is why a wide bar in the Performance panel means a long time.

    Why it fits here: It explains this topic's rule, wide is slow: the flame chart's x-axis is time, not the alphabet of a flame graph.

    Source: Brendan Gregg: Flame Graphs

    Sixty frames a second

    Smooth movement has a deadline. Most devices refresh their screens 60 times a second, so the browser has about 16.66 milliseconds to produce each frame. The browser has its own work in each frame, so web.dev advises fitting all of yours inside 10 milliseconds. Miss that budget, and the frame rate drops and the page judders on screen, which is called jank.

    Why it fits here: It gives the flame chart a ruler: during an animation, a bar wider than about 10 milliseconds will show on screen.

    Source: web.dev: Rendering performance

    In one line

    Record a few seconds with a CPU slowdown on. In the flame chart, wide means slow, stacked means caused, purple bars are layout, and a red corner marks a problem. A script's colour means nothing.

    One worker: the main thread

    At a glance

    A small tea stall has one person. They take orders, boil the tea, wash the glasses and give change, and if they stop to count the week's takings, the queue waits. A browser tab works the same way.

    Scripts, layout, paint and clicks all share one main thread, which does one thing at a time. Any task over 50 milliseconds is a long task, and while it runs, the page cannot answer. So answer first and work later, cut work into pieces, and read the page's sizes before you write new ones.

    Take a guess: Why does a page ignore your click while a long script is running?

    A small tea stall has one person. They take orders, boil the tea, wash the glasses and give change. If they stop to count the week's takings, the queue waits, however quick the counting is. A browser tab works the same way.

    main thread

    The one line of work on which a page's scripts run, and on which the browser does layout and paint and answers clicks. It can do only one thing at a time.

    long task

    Any single piece of work on the main thread that takes more than 50 milliseconds. While it runs, the page cannot draw or answer.

    A script that keeps the thread for 220 ms

    <!DOCTYPE html>
    <script>
      const end = performance.now() + 220;
      while (performance.now() < end) { }
    </script>

    Chrome measured

    Long tasks: 1

    The cure is to give the work in small pieces, so that the browser gets a turn between them. The same 200 milliseconds of work, cut into pieces of 20, is no long task at all.

    The same work in ten pieces

    <!DOCTYPE html>
    <script>
      let done = 0;
      function piece() {
        const end = performance.now() + 20;
        while (performance.now() < end) { }
        done = done + 1;
        if (done < 10) setTimeout(piece, 0);
      }
      piece();
    </script>

    Chrome measured

    Long tasks: 0

    A memory aid

    Do not hold the thread. Work in pieces under 50 milliseconds, and the page stays alive.

    Why a click feels slow

    INP measures from a tap to the next picture. If the click's handler keeps the thread for 300 milliseconds, nothing can change on the screen for all of that time, and the visitor taps again.

    Worked example 3

    A "Add to cart" button takes 300 milliseconds of work, and the page seems frozen. Make it answer at once, with the same work still done.

    What we have: a click handler that holds the thread for 300 ms

    What we need: an answer on the screen first, and the work afterwards

    The plan: change the screen, give the browser a chance to draw, then do the heavy work

    1. The handler does everything before the browser can paint, so the visitor sees nothing for 300 milliseconds.
    2. Make the small visible change first: the button says Added.
    3. Put the heavy work after the next picture: requestAnimationFrame runs just before a paint, and a setTimeout inside it runs just after.

    Before

    <!DOCTYPE html>
    <button>Add to cart</button>
    <script>
      function heavyWork() {
        const end = performance.now() + 300;
        while (performance.now() < end) { }
      }
      document.querySelector("button").addEventListener("click", function () {
        heavyWork();
        this.textContent = "Added";
      });
    </script>

    Chrome measured

    Slowest click: about 300 ms

    After

    <!DOCTYPE html>
    <button>Add to cart</button>
    <script>
      function heavyWork() {
        const end = performance.now() + 300;
        while (performance.now() < end) { }
      }
      document.querySelector("button").addEventListener("click", function () {
        this.textContent = "Added";
        requestAnimationFrame(function () {
          setTimeout(heavyWork, 0);
        });
      });
    </script>

    Chrome measured

    Slowest click: about 0 ms

    Answer first, then work. The same work is done, and the click takes almost no time.

    Check: Chrome measured the click at about 300 milliseconds before, and about 0 after.

    Forced layout: asking at the worst moment

    The browser saves up changes, and does one layout when it next draws. But if your script changes a style and then asks for a size, the browser must work out the layout at once, to answer truthfully. Do that in a loop, and you pay for a whole layout on every round. A forced layout appears as a purple Layout bar with a red corner, and the Summary tab links to the line.

    Worked example 4

    A price board sets the width of 200 rows, and reads each row's height. It is painfully slow. Find out why, and fix it, with the same result.

    What we have: a loop that writes a style, then reads a size, 200 times

    What we need: the number of layouts, and a way to reduce it

    The plan: separate them: do all the reads, then all the writes

    1. Each round changes a style, so the layout is out of date.
    2. The read that follows forces a fresh layout. That is 200 layouts in one go.
    3. Read everything first, while the layout is good, then write everything. The browser needs only one more.

    Write, then read, in each round

    <!DOCTYPE html>
    <style>
      body { margin: 0; }
      .row { height: 20px; }
    </style>
    <div class="list"></div>
    <script>
      document.querySelector(".list").innerHTML = '<div class="row">Rice</div>'.repeat(200);
      for (const row of document.querySelectorAll(".row")) {
        row.style.width = "300px";
        const height = row.offsetHeight;
      }
    </script>

    Chrome measured

    Layouts counted by Chrome: 200

    All the reads, then all the writes

    <!DOCTYPE html>
    <style>
      body { margin: 0; }
      .row { height: 20px; }
    </style>
    <div class="list"></div>
    <script>
      document.querySelector(".list").innerHTML = '<div class="row">Rice</div>'.repeat(200);
      const rows = document.querySelectorAll(".row");
      const heights = [];
      for (const row of rows) heights.push(row.offsetHeight);
      for (const row of rows) row.style.width = "300px";
    </script>

    Chrome measured

    Layouts counted by Chrome: 2

    Read first, write after. 200 layouts become 2, with the same result.

    Check: Chrome's own counter read 200, then 2.

    When you are stuck: the main thread

    A wide bar with a red corner: click it, and find the function in the Summary tab.

    Many thin purple bars: suspect a read after a write in a loop.

    A page freezes when something loads: a long task is holding the thread; split the work.

    Your turn

    How long is a long task?Tap to reveal
    1. A number of milliseconds.

    More than 50 milliseconds.

    Why can a page not answer a click during a long task?Tap to reveal
    1. One worker.

    The main thread is busy, and it does one thing at a time.

    How do you stop a loop from forcing a layout on each round?Tap to reveal
    1. Two loops.

    Do all the reads first, then all the writes.

    Did you know?

    Why 50 milliseconds

    The 50 milliseconds of a long task is no accident. The Long Tasks standard gives the sum: a site whose tasks all take under 50 ms should respond to input in under 100 ms. The task already running when the input arrives ends in under 50 ms, and the task that reacts to the input takes under 50 ms more.

    Why it fits here: It is where this topic's 50 milliseconds comes from: two short tasks in a row still feel instant.

    Source: Long Tasks API

    A tenth of a second

    The 100 ms goal is older than the web. In his 1993 book Usability Engineering, Jakob Nielsen wrote that 0.1 second is about the limit for having the user feel that the system is reacting instantaneously. He noted that the basic advice had been about the same for thirty years, citing Miller in 1968.

    Why it fits here: A tap answered within a tenth of a second feels instant; that feeling is what a long task takes away.

    Source: Nielsen Norman Group: Response Times, The 3 Important Limits

    In one line

    Scripts, layout, paint and clicks share one main thread, so a long task over 50 milliseconds freezes the page. Answer first and work later, cut work into pieces, and read before you write.

    A full inspection: Lighthouse

    At a glance

    The panels so far are tools for a mechanic who knows what to look for. Lighthouse is the yearly vehicle inspection. It goes through a long list of checks, and hands you a report with a score out of 100 for each area.

    It scores four categories: Performance, Accessibility, Best Practices and SEO, and it explains each problem it finds. Use it to learn where to look, and compare scores only on one machine. Then prove any speed work in the Performance panel, because Lighthouse points and the panel proves.

    Take a guess: If Lighthouse gives 72 today and 80 tomorrow, with no change to the page, what changed?

    The panels so far are tools for a mechanic who knows what to look for. Lighthouse is the yearly vehicle inspection: it goes through a long list, and hands you a report with a score for each area.

    Lighthouse

    A tool built into DevTools, as the Lighthouse panel, that loads a page, runs a long list of checks on it, and gives a score out of 100 in each of four categories, with advice for each problem found.

    CategoryIt looks at
    Performancethe speed numbers, and what is holding them back
    Accessibilityproblems a machine can find, such as missing alt text and low contrast
    Best Practicessafe, modern ways of working
    SEOwhether search engines can read the page

    Running it

    Open the Lighthouse panel, and choose what to check. Each choice changes what you get.

    ChoiceOptionsChoose
    ModeNavigation, Timespan, SnapshotNavigation for a page load; Timespan to check what you do on a page; Snapshot for the page as it stands
    DeviceMobile, DesktopMobile first: it is slower, and most visitors use it
    Categoriesany of the fourfewer run faster

    Then click Analyze page load. The page reloads and is put through its checks, which takes under a minute. Do not use the page while it runs.

    Reading the report

    PartWhat it gives
    the scoresone number from 0 to 100 for each category
    MetricsLCP, CLS and others, measured in this run
    Insights and Diagnosticswhat could be better, often with an estimate of the saving
    Passed auditswhat is already fine

    Each line opens to explain what it found, why it matters, and which elements are at fault. For a beginner, that is the real value of the report: it teaches, one problem at a time.

    How far to trust it

    RememberWhy
    two runs differthe score depends on what else your machine is doing
    your extensions affect itthey run in the page, so use an Incognito window
    compare only on one machinea score from another laptop means little
    100 for accessibility is not proofa machine finds only some problems; a real keyboard and screen reader find the rest
    PageSpeed Insights runs it elsewhereits server gives cleaner, more comparable runs, with field data

    For debugging speed, Chrome's own advice is to prefer the Performance panel, which now shows the same insights in more depth. Lighthouse remains the quick way to review the other three categories.

    A memory aid

    Lighthouse points; the Performance panel proves. A score is a guide to where to look, not the goal.

    Worked example 5

    A report lists three savings for a phone: compress images, 2.1 MB; remove unused scripts, 400 KB; shrink the CSS, 3 KB. On a connection of 1.6 megabits a second, how much time could each save, and which comes first?

    What we have: three savings in bytes, and a connection speed

    What we need: the time saved by each, and an order of work

    The plan: turn each into bits, divide by the speed, and start with the largest

    1. Images: 2.1 × 8 = 16.8 megabits, and 16.8 ÷ 1.6 = 10.5 seconds.
    2. Scripts: 0.4 MB × 8 = 3.2 megabits, and 3.2 ÷ 1.6 = 2 seconds.
    3. CSS: 3 KB × 8 = 24 kilobits, and 24 ÷ 1600 = 0.015 seconds.

    Images first, by far: 10.5 seconds, against 2 seconds and 0.015 seconds. The CSS saving is not worth an afternoon.

    Check: 2.1 MB is 700 times 3 KB, and 10.5 seconds is 700 times 0.015 seconds.

    When you are stuck: Lighthouse

    Scores jump between runs: close other work, use Incognito, and run it three times.

    A low score, and you do not know where to start: take the line with the largest saving.

    It says that a page is fine, and people complain: a lab test is not a visitor; look at field data.

    Your turn

    Name Lighthouse's four categories.Tap to reveal
    1. One is about speed.

    Performance, Accessibility, Best Practices, SEO.

    Which device should you test first?Tap to reveal
    1. The slower one.

    Mobile.

    Does an accessibility score of 100 mean that a page is accessible?Tap to reveal
    1. What can a machine not find?

    No: a machine finds only some problems.

    Did you know?

    What the score is made of

    The Performance score is a weighted sum of five measurements. In Lighthouse 10, Total Blocking Time carries the most, 30%, then Largest Contentful Paint and Cumulative Layout Shift with 25% each, and First Contentful Paint and Speed Index with 10% each. Total Blocking Time adds up how long the main thread was blocked after First Contentful Paint, so the thread topic counts most of all.

    Why it fits here: It tells you where a better score comes from: free the main thread first, then show the main content early and keep it still.

    Sources: Chrome for Developers: Lighthouse performance scoring; web.dev: Total Blocking Time

    Once five categories

    Lighthouse once had a fifth category, Progressive Web App. Its version 12 removed it, as per Chrome's updated installability criteria, in a release whose notes speak of the priorities of Google search in 2024. Lighthouse itself is open source, and it runs in Chrome DevTools, from the command line or as a Node module.

    Why it fits here: It explains why this topic counts four categories, while older guides and pictures of reports show five.

    Sources: Lighthouse on GitHub: release v12.0.0; Chrome for Developers: Introduction to Lighthouse

    In one line

    Lighthouse scores a page on performance, accessibility, best practices and SEO, and explains each problem. Use it to find where to look, compare only on one machine, and prove speed work in the Performance panel.

    Time it first

    At a glance

    Every programmer has a theory about what is slow, and every programmer is often wrong. A fix aimed at the wrong thing costs time and changes nothing. Time spent on the wrong fix is time taken from the right one.

    So the rule is plain: measure, change one thing, and measure again. Set a phone's conditions, read the three numbers and take the worst. Record the worst moment, find the widest bar, and change that one thing. If the number does not move, that thing was not the cause.

    Take a guess: If a change does not move the number you measured, what does that tell you?

    Every programmer has a theory about what is slow, and every programmer is often wrong. The fix for a slow page costs time, and a fix aimed at the wrong thing changes nothing. So the rule is plain: measure, change one thing, and measure again.

    StepDo thisWhy
    1Set a phone's conditions: a CPU slowdown, and Slow 4Gyour laptop hides the problem
    2Read the three numbers, and take the worstfix what visitors feel most
    3Record the moment that number measuresfor INP, the click; for LCP, a reload
    4Find the widest bar, or the top of Bottom-upwork on the largest thing
    5Change one thingso that you know what helped
    6Measure again, in the same conditionsa change that did not move the number was not the cause
    The numberUsual causesLook first at
    LCP is slowa huge image, a slow server, a page built by script, a main image marked lazythe LCP card's element, then its row in the Network panel
    INP is slowa long task in a handler, forced layoutsa recording of the click
    CLS is highimages with no size, late banners, late fontsLayout Shift Regions

    Lazy loading the main image

    loading="lazy" is for images far down the page. On the main image at the top, it makes the browser wait before it even asks for the picture, and LCP suffers. Leave it off anything visible when the page opens.

    A memory aid

    Measure, change one thing, measure again.

    Worked example 6

    The Exchange's board feels slow to tap. Corin wants to shrink the pictures. The INP card shows 600 milliseconds, and images were loaded long before the tap. What do you do?

    What we have: a slow tap, and a theory about pictures

    What we need: where the time really goes

    The plan: INP is about what happens after a tap, so record a tap, and read the widest bar

    1. The pictures loaded long before the tap. They cannot be what the tap is waiting for, so the theory fails before any work is done.
    2. Set a 4x CPU slowdown, click Record, tap the board, and click Stop.
    3. The widest bar is a Task with a red corner. Under it, a function has hundreds of thin purple Layout bars.
    4. That is the forced layout of the last section. Read first, write after.
    5. Measure again in the same conditions. The number falls, which is the proof.

    One line, not the pictures. A number that measures a tap cannot be cured by work on loading.

    Check: in the thread section, the same change took Chrome from 200 layouts to 2.

    When you are stuck: speed work

    You do not know which number to work on: the worst one, measured with phone settings.

    A change made no difference: then it was not the cause; undo it, and look again.

    The page is slow only sometimes: record several runs; suspect something that loads late.

    Your turn

    What is the first step when a page feels slow?Tap to reveal
    1. Your laptop hides things.

    Set a phone's conditions, and measure.

    Why change one thing at a time?Tap to reveal
    1. What did the good?

    So that you know what helped.

    Should the main image at the top of a page be lazy?Tap to reveal
    1. It is visible at once.

    No: that delays LCP.

    Did you know?

    The root of all evil

    The warning against guessing is old. In December 1974, in "Structured Programming with Goto Statements", Donald Knuth wrote that "we should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil". Yet, he added, we should not pass up our opportunities in that critical 3%. Measuring is how you find that 3%.

    Why it fits here: This topic's rule is Knuth's in practice: measure to find the critical part, and leave the rest alone.

    Sources: Wikiquote: Donald Knuth; Wikipedia: Program optimization

    Scores that move by themselves

    Scores move even when code does not. Lighthouse's own documentation warns that performance scores will change due to inherent variability in web and network technologies, even if there has not been a code change. It advises running Lighthouse multiple times before drawing conclusions about a change. One run proves little; several runs on one machine prove more.

    Why it fits here: It is why this topic measures again after each change, and why one lucky score is not proof.

    Source: Lighthouse on GitHub: Score Variability

    In one line

    Set a phone's conditions, read the three numbers, record the worst moment, find the widest bar, change one thing, and measure again; a change that does not move the number was not the cause.

    Where it is used

    Large shops and news sites measure these numbers every day, because a slower page sells less.

    What you learnedWhere it is usedA real example
    the three numberstracking a site's healtha shop's weekly report of LCP on phones
    reserving spacepages with late contenta news site holding a place for each advertisement
    a recordingfinding a slow interactionseeing why typing in a search box lags
    read first, write afterlists and tablesa price board that updates 200 rows
    answer first, work laterbuttonsa Like button that changes at once and saves afterwards
    Lighthousea quick reviewchecking a new page before it goes out
    CPU and network slowdowntesting for real visitorsseeing a page as on a low-priced phone

    Mistakes and debugging

    These are the speed slips everyone makes.

    1. Fixing what you guessed

    You spend a day on images, and the number does not move. The fix: time it first.

    2. Testing on your own laptop

    A fast machine on good Wi-Fi hides every problem. The fix: a CPU slowdown and Slow 4G, every time.

    3. Chasing the score

    A hundred from Lighthouse is pleasant, and it is not the goal. A page can score well and feel slow to real visitors. The fix: work on what visitors feel, and watch field data.

    4. Comparing unlike runs

    Your numbers with other work running, against numbers without it, mean nothing. The fix: the same machine, the same settings, several runs.

    5. Forgetting that DevTools costs something

    With DevTools open, a page runs a little slower, and recording adds more. The fix: trust the differences between runs more than any one figure.

    6. Images with no size

    Each one jumps the page as it arrives. The fix: width and height on every image.

    7. Reading a size in a loop that writes

    Each round forces a layout. The fix: read first, write after.

    8. Doing everything on a click

    The page freezes, and the visitor taps again. The fix: show the change at once, and do the slow work after the next paint.

    The debugging corner: before and after

    Before you start, note the three numbers and the widest bar, with your phone settings on. After your change, take them again in the same conditions. Comparing the two is the honest way to show that a change helped, and it makes a clear report for a teammate.

    Quick card

    The lesson on one card.

    NumberAsksGoodUsual cure
    LCPis it here?2.5 seconds or lesssmaller images, a quicker server
    INPdoes it answer?200 milliseconds or lessshorter tasks, answer first
    CLSdoes it keep still?0.1 or lesssizes on images, reserved space
    To do thisDo this
    see the numbersopen the Performance panel
    film what happensRecord, use the page, Stop
    film a loadRecord and reload
    act like a phoneCPU 4x or 20x slowdown, and Slow 4G
    find the slow functionthe flame chart's widest bar, or Bottom-up
    see what repaintsthe Rendering tab, Paint flashing
    see what jumpsthe Rendering tab, Layout Shift Regions
    review a whole pagethe Lighthouse panel, Mobile
    In a flame chartMeans
    a wider barit took longer
    bars stackedthe upper one caused the lower
    purplelayout
    a red cornera long task, or a forced layout
    red shadingthe part of a task past 50 milliseconds

    And the rule of the sixth lens: time it first, change one thing, and time it again.

    The story: Time it first

    The clock lens records the board for a few seconds, and lays the work out in bars. One bar towers over the rest. Inside it, a single function measures every row of the board, then moves it, then measures the next, two hundred times.

    You move one line, so that it measures all the rows first and moves them afterwards. The board answers at once. You give the pictures their sizes before they arrive, and the figures stop jumping.

    Ottilie looks at Corin. "What did you guess?" "The pictures," he says. "And what was it?" He looks at the bench. "One line."

    Reagents gathered: Performance panel, LCP, INP, CLS, long task, Lighthouse.

    Sources

    • Chrome DevTools documentation (Page content CC BY 4.0, code samples Apache 2.0 (the footer of its pages, read 2026-11-06); reused with credit)
    • web.dev, Web Vitals and performance articles (Page content CC BY 4.0, code samples Apache 2.0 (the footer of its pages, read 2026-11-06); reused with credit)
    • MDN Web Docs (Prose CC BY-SA 2.5 or later; code samples added since 2010-08-20 CC0 (its licensing page, read 2026-10-26); reused with credit)