Loading

Fact dictionary

Browser DevTools

71 facts from 7 lessons of Browser DevTools. Each one names its source and leads back to its place in the lesson.

Lesson 1: The Elements panel

The first Web Inspector, 2006

The Elements panel and the Styles pane are older than they look. On 16 January 2006, Timothy Hatcher introduced the Web Inspector, a new addition to WebKit. It let you browse the live DOM hierarchy, it highlighted each node on the page as you selected it, and its Style pane showed all the CSS rules that applied to the chosen node.

Why it fits here: The panels this topic opens do the same jobs that first inspector did.

Source: WebKit blog: Introducing the Web Inspector

Topic: Opening the lens: DevTools · history, people, browsers

A new Chrome every four weeks

DevTools changes faster than most guides about it. Google moved Chrome to a new stable version every four weeks, down from six, and planned Chrome 94, due on 21 September 2021, as the first release on that schedule. Each release has its own notes, such as What's new in DevTools (Chrome 120). So a button may sit somewhere other than an older guide says.

Why it fits here: It is why this topic teaches what each panel is for rather than where each button sits: buttons move, jobs stay.

Sources: Chrome for Developers: Speeding up Chrome's release cycle; Chrome for Developers: What's new in DevTools (Chrome 120)

Topic: Opening the lens: DevTools · browsers, numbers

The DOM became a standard in 1998

The name DOM comes from a W3C standard. The Document Object Model Level 1 became a W3C Recommendation on 1 October 1998. It defined the DOM as a platform- and language-neutral interface that lets programs and scripts access and update the content, structure and style of documents while they are open.

Why it fits here: The tree this topic shows in the Elements panel is that same object model, read by DevTools.

Source: W3C: Document Object Model Level 1

Topic: The DOM tree: what the browser really built · history, standards

Every node has a number

Each node in the tree carries a number, its nodeType, fixed by the DOM standard. An element is 1, a piece of text is 3, a comment is 8 and the whole document is 9. Three numbers, 5, 6 and 12, are marked legacy in the standard. The Elements panel draws these same nodes, element by element, as its tree.

Why it fits here: The tree in this topic is made of these nodes: elements, text and comments, each with its own number.

Source: WHATWG: DOM Standard

Topic: The DOM tree: what the browser really built · standards, numbers

Layers in the cascade

The cascade gained a new step in 2022. Cascade layers, the @layer rule, came to Chromium 99, Firefox 97 and Safari 15.4 Beta, to give more explicit control of CSS files and prevent conflicts of specificity. Between layers, the standard says, a normal rule in the last layer wins. DevTools can show each rule's cascade layer in the Styles pane.

Why it fits here: It adds one more reason to this topic's question of who won: a rule can lose because of its layer.

Sources: Chrome for Developers: Cascade layers are coming to your browser; W3C: CSS Cascading and Inheritance Level 5; Chrome for Developers: What's New In DevTools (Chrome 99)

Topic: The Styles tab: every rule, and who won · standards, history

Two kinds of pale text

Pale text in the Styles tab means one of two things. Chrome's own guide says properties that are valid but have no effect, because of other properties, are shown pale with information icons: they are inactive because of CSS logic, not because of the cascade. Pale properties without an icon are a different case: in the Inherited from sections, properties that do not inherit by default are shown in pale text.

Why it fits here: It sharpens this topic's rule: pale with an icon needs something else; pale without one was never passed down.

Source: Chrome for Developers: Find invalid, overridden, inactive, and other CSS

Topic: The Styles tab: every rule, and who won · browsers

You write red, it says rgb

The Computed tab speaks a stricter language than you write. Write color: red, and the computed value is the matching sRGB colour; the CSS Color standard says such colours are written out in the rgb() or rgba() form. So the Computed tab, like getComputedStyle, reports rgb(255, 0, 0) for red. Your words go in, and the browser's numbers come out.

Why it fits here: It is why a value in this topic's Computed tab may look unlike the line you wrote, while meaning the same thing.

Source: W3C: CSS Color Module Level 4

Topic: The Computed tab: the final answer · standards, colour

Computed is not quite computed

The word computed has a history. The script that reads these values, getComputedStyle(), was first defined to return computed values. Then the meaning of computed value changed between versions of CSS, while old scripts still needed the old answers. So the CSSOM standard gave those answers a new name of their own: resolved values.

Why it fits here: It explains why the numbers in this topic's Computed tab are called resolved values in the standards.

Source: W3C: CSS Object Model

Topic: The Computed tab: the final answer · history, standards, words

When the whole page is odd

One CSS mystery has nothing to do with your rules. The HTML standard says that DOCTYPEs are required for legacy reasons: without one, browsers tend to use a different rendering mode, incompatible with some specifications, known as quirks mode. Chrome 90 began to report quirks mode in DevTools' Issues tab. So when sizes and spacing make no sense at all, read the first line of the file.

Why it fits here: It adds one question to this topic's method: before blaming a rule, make sure the page is not in quirks mode.

Sources: WHATWG: HTML Standard, The HTML syntax; Chrome for Developers: What's New In DevTools (Chrome 90)

Topic: Look first: a method for any CSS mystery · standards, mistakes, browsers

The detective's rule

Detectives use the same method as this topic. A CSS mystery yields to their habit: rule out, one by one, what cannot be the cause. In The Sign of the Four, first published in February 1890, Sherlock Holmes asks: "How often have I said to you that when you have eliminated the impossible, whatever remains, however improbable, must be the truth?"

Why it fits here: This topic's method works by elimination: the wrong element, the missing rule and the crossed-out rule are ruled out in turn.

Sources: Wikisource: The Sign of the Four, Chapter 6; Wikisource: The Sign of the Four

Topic: Look first: a method for any CSS mystery · books, people, tricks

Lesson 2: The Console

The first logs were made of wood

The word log began at sea. In the days of sail, sailors tied a piece of wood, a log, to a rope knotted at regular gaps off the back of the ship. They counted the knots that passed through their hands in a set time to find the ship's speed. That is why speed at sea is still given in knots. A ship's logbook was first a book for writing down those readings.

Why it fits here: This topic calls the Console a page's logbook, and the word log itself began with a piece of wood on a knotted rope.

Sources: Wikipedia: Chip log; Wikipedia: Ship's log; Wiktionary: knot

Topic: The page's diary · words, history, real life

Message levels from the 1980s

Sorting messages by how serious they are is an old idea. Syslog, a standard for message logging, was developed in the 1980s by Eric Allman as part of the Sendmail project. It became the standard logging solution on Unix-like systems. Its standard of March 2009, RFC 5424, numbers eight severities, from 0, Emergency, "system is unusable", to 7, Debug. Error, Warning, Informational and Debug are among them, close to the console's own error, warn, info and debug.

Why it fits here: The Console's levels are one case of an old habit: grade each message, so that the serious ones can be found first.

Sources: Wikipedia: Syslog; RFC 5424: The Syslog Protocol; Console Standard

Topic: The page's diary · history, people, standards

A standard that says please

The console methods have a written standard, the Console Standard, which defines APIs for console debugging facilities. Its status note calls it an early work in progress, and asks readers to be kind and constructive, because it is its editors' first specification. Its entry for console.table asks the browser to build a table, or else fall back to logging the argument. Then it adds a note to itself: "TODO: This will need a good algorithm."

Why it fits here: It shows that standards are written by people, and that console.table, given data it cannot draw as a table, falls back to a plain log.

Source: Console Standard

Topic: Writing in the diary · standards, people

Messages in colour

A console message can be styled with CSS. The format specifiers of the Console include %s, which formats a value as a string, and %d, which formats it as an integer. One more, %c, "Applies provided CSS". Chrome's documentation shows it at work: console.log("%cHooray", style) prints Hooray in the styles given as the second value, such as a dark blue background with white text.

Why it fits here: A styled label makes your own messages stand out among the hundreds of lines a real page can log.

Sources: Chrome for Developers: Format and style messages in the Console; Console Standard

Topic: Writing in the diary · tools, colour

Ten frames, and why

In Chrome, an error's stack property normally holds at most ten calls. V8, the JavaScript engine used in Chrome and in Node.js, gives almost every error a stack property holding the topmost 10 stack frames. Its makers chose 10 because it is usually enough to be useful without a noticeable cost in speed. Setting Error.stackTraceLimit changes the number, and Infinity collects every frame. The stack property itself is not standardized: MDN marks it Non-standard.

Why it fits here: It explains why a very long chain of calls can be cut short in a stack trace, and how to collect all of it.

Sources: V8; V8: Stack trace API; MDN: Error.prototype.stack

Topic: Reading an error · browsers, numbers, standards

TypeError, the catch-all

TypeError turns up for many different slips, and the JavaScript standard says why. It uses TypeError for an unsuccessful operation when none of the other error types fits the cause. MDN lists such cases. One is a value of a type that the operation does not expect. Another is a change to a value that cannot be changed, and a third, a value used in a way that does not suit it. EvalError has the opposite fate. The standard does not use it at all now, and keeps it only for compatibility with earlier editions.

Why it fits here: Most red lines in this topic's table are TypeErrors, and this is the reason: the standard makes TypeError the error for anything without a better name.

Sources: ECMAScript Language Specification; MDN: TypeError

Topic: Reading an error · standards, mistakes

Type allow pasting

The Console is powerful enough to be dangerous. In an attack called Self-XSS, attackers trick people into pasting harmful code into DevTools, which can hand over their web accounts and personal information. So since Chrome 120, a new DevTools user who tries to paste into the Console sees a warning, and must type allow pasting first. Once pasting has been allowed once, the warning never shows again.

Why it fits here: It is the safety rule of this topic: paste into the Console only code that you understand and have read yourself.

Source: Chrome for Developers: What's new in DevTools (Chrome 120)

Topic: Asking the page questions · privacy, browsers

Five picks remembered

The Console remembers more than your last pick. The names $0, $1, $2, $3 and $4 refer to the last five elements you inspected in the Elements panel, with $0 the most recent. The $ helper also gives way to the page. If the page uses a library such as jQuery that defines its own $, the library's $ is the one you get.

Why it fits here: It saves typing: inspect a few elements in turn, then compare them in the Console as $0 to $4.

Source: Chrome for Developers: Console Utilities API reference

Topic: Asking the page questions · tools, browsers

A log that changes after the fact

A logged object can mislead. MDN warns that information about an object is lazily retrieved: the Console shows its contents as they are when you first open it, not as they were when it was logged. DevTools marks such a value with a small note, whose source code reads: This value was evaluated upon first expanding. It may have changed since then. MDN's cure is to log a deep copy.

Why it fits here: It matters for this topic's method: when you log what you expect at each stage, log a copy, or the log may show a later value.

Sources: MDN: console; Chrome DevTools frontend source: ConsoleViewMessage.ts

Topic: From the first red line to the fix · tools, mistakes

Bugs that hide when watched

Sometimes looking at a bug changes it. A heisenbug is a bug that seems to disappear or change when you try to study it. The name is a pun on Werner Heisenberg, the physicist who first introduced the uncertainty principle. Adding output statements can alter a program in subtle ways, such as the timing of its run. The earliest known use of the word is from 1983, in an ACM publication.

Why it fits here: It explains a strange moment in debugging: a bug that hides as soon as you add a log to look for it.

Sources: Wikipedia: Heisenbug; Wiktionary: heisenbug

Topic: From the first red line to the fix · words, science, mistakes

Lesson 3: The Network panel

Seventy parcels for one page

A page that looks like one thing is many requests. The Web Almanac of 2024 found that the median desktop page makes 71 requests, with 24 JavaScript files, 18 images, 8 CSS files, 4 fonts and 2 HTML files among them. The median mobile page makes 66. So the requests table of an ordinary page has about seventy rows.

Why it fits here: It shows why this topic's filters and sorting matter: an ordinary page fills the table with about seventy rows.

Source: The Web Almanac: Page Weight, 2024

Topic: Every parcel the page asked for · numbers, internet

A saved table, cleaned by default

The whole requests table can be saved as one file, a HAR, short for HTTP Archive. It is a JSON object with a particular set of fields, used by several HTTP session tools. Such a file can leak secrets, so Chrome exports a sanitized HAR by default, without the Cookie, Set-Cookie and Authorization headers. A version with the sensitive data must be chosen on purpose.

Why it fits here: Before you send a HAR to anyone for help, keep the sanitized one: cookies and sign-in headers can travel inside the other.

Sources: Chrome for Developers: Network features reference; Wikipedia: HAR (file format)

Topic: Every parcel the page asked for · privacy, tools

Only 100 to 599

A status code is always a three-digit number, and not every three digits will do. The HTTP standard, RFC 9110, says that values outside the range 100 to 599 are invalid, though programs often use 600 to 999 among themselves for problems that are not HTTP's. Within the range, the first digit defines the class, and the last two digits play no part in it.

Why it fits here: It explains this topic's families: every real answer starts with a digit from 1 to 5, and that digit says who to blame.

Source: RFC 9110: HTTP Semantics

Topic: What the server answered · standards, numbers

No words in HTTP/2

In HTTP/1.1, the first line of an answer carries the code and, after it, a short reason phrase, such as 404 Not Found. HTTP/2 kept only the number. Its first standard, RFC 7540 of May 2015, says that HTTP/2 does not define a way to carry the reason phrase of an HTTP/1.1 status line. So in a script, response.statusText comes back empty for HTTP/2.

Why it fits here: It is why this topic reads the number: the number always travels, while the words may not.

Sources: RFC 9112: HTTP/1.1; RFC 7540: HTTP/2; MDN: Response.statusText

Topic: What the server answered · standards, words

Misspelt in the standard

One header is spelt wrongly, and has stayed that way. The field that tells a server which page an address came from is called Referer, with one r too few. The HTTP standard, RFC 9110, writes it as "Referer" [sic] and admits that the field name is misspelled. The spelling came from the original proposal by Phillip Hallam-Baker, and it was set in stone by May 1996, when it entered RFC 1945.

Why it fits here: In the Headers tab you will meet referer spelt this way; it is the standard's spelling, not a typing slip of the site.

Sources: RFC 9110: HTTP Semantics; Wikipedia: HTTP referer

Topic: Opening one request · words, standards, mistakes

Small letters in HTTP/2

Header names in DevTools often appear in small letters, such as content-type, and the standards explain why. RFC 9110 says that field names are case-insensitive, so Content-Type and content-type name the same header. RFC 9113, the standard for HTTP/2, goes further: field names must be converted to lowercase when an HTTP/2 message is built. So a site served over HTTP/2 shows them all in small letters.

Why it fits here: When you read or search the Headers tab, the case of a name does not matter: Content-Type and content-type are one header.

Sources: RFC 9110: HTTP Semantics; RFC 9113: HTTP/2

Topic: Opening one request · standards, internet

XHR, a name older than its use

The XHR in the Fetch/XHR filter is XMLHttpRequest, a JavaScript API to create HTTP requests. Despite its name, it can retrieve any type of data, not just XML. Its own standard records that it was first defined as part of the WHATWG's HTML work, based on Microsoft's implementation many years before, and that it moved to the W3C in 2006. The newer Fetch API is a more powerful and flexible replacement for it.

Why it fits here: It explains the filter's name: Fetch/XHR holds both ways that scripts ask for data, the newer and the older.

Sources: MDN Glossary: XHR (XMLHttpRequest); MDN: XMLHttpRequest; XMLHttpRequest Standard; MDN: Fetch API

Topic: Opening one request · history, words, browsers

Pages four times heavier

Pages keep getting heavier. The Web Almanac of 2024 measured the median mobile page at 505 KB in October 2014, and at 2311 KB in October 2024, more than four times as much. The median desktop page grew from 1208 KB to 2652 KB over the same years. On a limited data pack, every one of those kilobytes is paid for.

Why it fits here: It is why the Size column matters: a page's weight is a cost that every visitor on mobile data pays.

Source: The Web Almanac: Page Weight, 2024

Topic: Slow and heavy · numbers, internet

The Performance Golden Rule

Most of a visitor's waiting happens after the server answers. Steve Souders called this the Performance Golden Rule: 80 to 90% of the end-user response time is spent on the frontend. He counted as backend the time for the server to send the first byte back, and as frontend everything else, downloading every file the page refers to included. Checking the top 10 websites in 2012, he found that the frontend took 76% on average.

Why it fits here: In the Timing tab, Waiting (TTFB) is Souders' backend; the downloads after it are the frontend, where most of the time usually goes.

Source: Steve Souders: the Performance Golden Rule

Topic: Slow and heavy · numbers, people, internet

The Monkey, 1983

Making things fail on purpose is an old trick. While the first Macintosh was being built, Steve Capps wrote a testing tool he called The Monkey. It was a small desk accessory that fed random events to the current program, so the Macintosh seemed to be worked by an incredibly fast, somewhat angry monkey, banging at the mouse and keyboard. Andy Hertzfeld tells the story, dated October 1983.

Why it fits here: Request blocking is the same idea, aimed at one file: break it on purpose, and watch what your page does.

Source: Folklore.org: Monkey Lives

Topic: Which panel, which question · history, people, machines

Chaos Monkey

Netflix took the monkey to its servers. In 2011, while moving Netflix to the cloud, Nora Jones, Casey Rosenthal and Greg Orzell set up a tool that caused breakdowns in the production environment that customers used. Chaos Monkey, invented in 2011, randomly terminates virtual machine instances and containers. Its makers explain why: exposing engineers to failures more often pushes them to build services that survive them.

Why it fits here: A good page is built the same way: expect requests to fail, and test that the page still tells the reader something useful.

Sources: Wikipedia: Chaos engineering; Netflix on GitHub: Chaos Monkey

Topic: Which panel, which question · history, tools, internet

Lesson 4: The Sources panel and breakpoints

Source maps, a standard since 2024

The code a browser runs is often not the code that was written, because tools compile it first. A source map links the two, so that developer tools can show the original. Its format became an Ecma standard, ECMA-426, in a first edition of December 2024. It aims at source-level debugging with mapping in both directions, for code compiled to JavaScript, WebAssembly and CSS.

Why it fits here: If the Sources panel shows your original files on a built site, a source map is doing that work.

Source: Ecma International: ECMA-426

Topic: The room with the machine in it · standards, tools

Changes that survive a reload

Edits made in DevTools vanish when you reload, unless you ask DevTools to keep them. With local overrides, DevTools saves a copy of the modified file to a folder you choose. When you reload the page, DevTools serves that local file instead of the one from the network. Chrome's documentation suggests it for testing fixes before they go to production, without waiting for the backend.

Why it fits here: It answers a common wish: to try a change to a page's file and keep it across reloads, with no server of your own.

Source: Chrome for Developers: Override web content and HTTP response headers locally

Topic: The room with the machine in it · tools, tricks

A keyword that may do nothing

The keyword debugger belongs to JavaScript's own standard, but the standard promises little. Evaluating it may allow an implementation to cause a breakpoint when run under a debugger. If a debugger is not present or active, the statement has no observable effect. So a debugger line forgotten in a file does nothing to visitors who never open DevTools, and pauses only for those who do.

Why it fits here: It is why debugger is safe to try in these blocks, and why it should still be taken out before a page goes live.

Source: ECMAScript Language Specification

Topic: Stopping the machine · standards, tools

A breakpoint in one byte

Debuggers of native programs can set a breakpoint with a single byte. On x86 processors, the INT3 instruction is a one-byte instruction defined for use by debuggers: they put it in place of an instruction of the running program, for a while, to set a code breakpoint. Microsoft's documentation shows the same idea behind __debugbreak(), its portable way to cause a breakpoint, which on x86 is similar to int 3.

Why it fits here: It shows how old and plain the idea of this topic is: mark a place, and the machine stops there for you.

Sources: Wikipedia: INT (x86 instruction); Microsoft Learn: __debugbreak

Topic: Stopping the machine · machines, tools

The same keys elsewhere

The step keys are shared beyond Chrome. In Chrome DevTools, F10 steps over the next function call, F11 steps into it, and Shift + F11 steps out of the current function. Microsoft's Visual Studio uses the same three keys: F10 for Step Over, F11 for Step Into and Shift + F11 for Step Out. Learn them once, and they work in both.

Why it fits here: The buttons of this topic have keys, and the keys travel: the same moves work in other debuggers too.

Sources: Chrome for Developers: Keyboard shortcuts; Microsoft Learn: Navigate through code with the Visual Studio debugger

Topic: One tooth at a time · tools, tricks

next, step and finish

Command-line debuggers have the same three moves under other names. In GDB, the GNU debugger, the command next goes on to the next source line, and function calls within that line run without stopping. The command step goes inside any function called within the line. The command finish runs until the current function returns, then prints the returned value. GDB's manual names Richard Stallman as its original author.

Why it fits here: Over, into and out are not Chrome's inventions: debuggers share them, so what this topic teaches works far beyond the browser.

Sources: GDB manual: Continuing and Stepping; GDB manual: Contributors to GDB

Topic: One tooth at a time · tools, people, history

Logpoints, from Chrome 73

Logpoints came to Chrome in version 73, whose release notes put them first. Their purpose fits in one line: use logpoints to log messages to the Console without cluttering up your code with console.log() calls. You add one by right-clicking a line number. The page's own files stay untouched, so nothing has to be cleaned up afterwards.

Why it fits here: It is the kind of breakpoint to reach for when you only want to read a value, and not stop the page.

Source: Chrome for Developers: What's New In DevTools (Chrome 73)

Topic: The right pin for the job · tools, history, browsers

Watchpoints, hundreds of times slower

Other debuggers have a breakpoint that watches a value instead of a line. GDB calls it a watchpoint, sometimes called a data breakpoint: it stops whenever the value of an expression changes, without having to predict where. Done in software, GDB single-steps the program and tests the value each time, which its manual says is hundreds of times slower than normal execution.

Why it fits here: A DOM change breakpoint works in the same spirit for an element: you say what to watch, and the browser finds the line.

Source: GDB manual: Setting Watchpoints

Topic: The right pin for the job · tools, numbers

One sign, two jobs

JavaScript's + does two jobs, and its standard says so in one line: the addition operator either performs string concatenation or numeric addition. The steps that follow give the rule. If either side is a String, both sides are turned into text and joined. So "7" + 3 gives "73", while 7 + 3 gives 10.

Why it fits here: It explains the bug this topic hunts: a price read from the page is text, and + joins it instead of adding.

Source: ECMAScript Language Specification

Topic: Finding what logs would hide · standards, mistakes, maths

The value not equal to itself

One wrong value hides well: NaN, a value representing Not-A-Number. It is the only value that compares unequal to itself, so NaN === NaN is false, and a test such as price === NaN can never be true. To tell whether a value is NaN, MDN advises Number.isNaN() or isNaN(), or the self-comparison x !== x.

Why it fits here: In the Scope pane, NaN looks like any other value; reading every value, as this topic does, is how you catch it.

Sources: MDN: NaN; ECMAScript Language Specification

Topic: Finding what logs would hide · maths, mistakes

Lesson 5: The Application panel and storage

One locker per origin

Each set of lockers belongs to an origin, not to a whole site. Two addresses share an origin only if the protocol, the port and the host are all the same. The localStorage of a page belongs to the document's origin, so the http and https versions of a site, or two of its subdomains, see separate stores. The HTML standard calls origins the fundamental currency of the web's security model.

Why it fits here: If a stored value seems to vanish, check the address bar: another protocol or subdomain opens another set of lockers.

Sources: MDN: Same-origin policy; MDN: Window.localStorage; HTML Standard: Origins

Topic: What the browser keeps for a site · internet, privacy

A sixth drawer, closed

There was once another drawer: Web SQL, a database in the browser that used SQL. Work on its standard stopped in 2010 at an impasse, because every interested implementor had used the same backend, SQLite, and a standard needs several independent ones. Firefox never implemented it. Chrome took it away in steps, and from Chromium 119 it is no longer available anywhere.

Why it fits here: It is why the panel's database drawer is IndexedDB: the W3C points those who need a web database there instead.

Sources: W3C: Web SQL Database; Chrome for Developers: Deprecating and removing Web SQL

Topic: What the browser keeps for a site · history, standards, browsers

Five megabytes each

These two drawers are small. Browsers can store up to 5 MiB of localStorage and 5 MiB of sessionStorage for each origin. When that limit is reached, the browser throws a QuotaExceededError, which the page's code should handle. A list of short notes fits with room to spare; a single large photograph may not.

Why it fits here: It is one more reason this topic keeps only small text here, and sends large data to IndexedDB.

Sources: MDN: Storage quotas and eviction criteria; HTML Standard: Web storage

Topic: Two drawers of text: localStorage and sessionStorage · numbers, standards

Tabs that talk

One tab can learn of another tab's change through storage. When a document changes a storage area, the browser fires a storage event in every other document that shares that area, but not in the window that made the change. The event carries the key, the old value, the new value and the address of the page. So two open tabs of one shop can keep a cart in step.

Why it fits here: If a value changes in one tab while another is open, this event is how the second tab can find out.

Sources: MDN: Window storage event; HTML Standard: Web storage

Topic: Two drawers of text: localStorage and sessionStorage · tricks, standards

Four hundred days at most

A cookie cannot ask to live for ever. As of Chrome 104, in August 2022, cookies can no longer set an expiration date more than 400 days in the future. A cookie that asks for longer is not rejected; its date is set to 400 days instead. The revision of the cookie standard recommends the same limit, 400 days, which is about thirteen months.

Why it fits here: It explains a date in this topic's cookie columns: an Expires far in the future is cut back to 400 days.

Sources: Chrome for Developers: Cookie Expires and Max-Age attributes now have upper limit; IETF: Cookies: HTTP State Management Mechanism (rfc6265bis)

Topic: The drawer that travels: cookies · numbers, privacy, browsers

Floors, not ceilings

The cookie standard, RFC 6265, sets floors, not ceilings. A browser should allow at least 4096 bytes per cookie, counting its name, value and attributes, at least 50 cookies per domain and at least 3000 cookies in all. Servers, for their part, should use as few and as small cookies as possible, to avoid reaching those limits. Every cookie also rides along with every request to its site, so small ones keep each request light.

Why it fits here: This topic's cookies hold a short key, not data: the floors are small, and the browser sends each cookie every time.

Source: RFC 6265: HTTP State Management Mechanism

Topic: The drawer that travels: cookies · numbers, standards

Room measured in gigabytes

The large drawers are large indeed. In Chrome, the browser may use up to 80% of total disk space, and one origin up to 60%. MDN gives an example: on a device with a 1 TiB drive, one origin may use up to 600 GiB. Compare that with the 5 MiB of localStorage, and the reason for IndexedDB is plain.

Why it fits here: It shows why this topic sends big data to IndexedDB: its room is measured in gigabytes, not megabytes.

Sources: web.dev: Storage for the web; MDN: Storage quotas and eviction criteria

Topic: The two large drawers, and the Clear button · numbers, browsers

A header that empties the drawers

The Clear site data button has a twin on the server's side. A site can send the Clear-Site-Data header to instruct the browser to clear the data it stores for that site, such as "cache", "cookies" and "storage". The standard's first example is signing out: the site wants the locally stored data removed as the user leaves.

Why it fits here: A sign-out that only forgets the cookie may leave other drawers full; this header empties them all at once.

Source: W3C: Clear Site Data

Topic: The two large drawers, and the Clear button · standards, privacy

No secrets in localStorage

The security community puts this topic's rule in plain words. OWASP's HTML5 Security Cheat Sheet says: do not store session identifiers in local storage, as the data is always accessible by JavaScript. Cookies can lower that risk with the HttpOnly flag. With it, browsers that support it keep the cookie out of JavaScript APIs such as document.cookie.

Why it fits here: It is the reason for this topic's last rule: a sign-in key in localStorage is open to every script on the page.

Sources: OWASP: HTML5 Security Cheat Sheet; OWASP: HttpOnly

Topic: Too much memory, or too little · privacy, mistakes

HttpOnly, since 2002

HttpOnly is more than twenty years old. Microsoft first added support for it in Internet Explorer 6 SP1, around 2002. Over time it became part of all major browsers, and it is now treated as a standard cookie attribute: the cookie standard says it limits the scope of the cookie to HTTP requests. One word in the Set-Cookie header is enough.

Why it fits here: A sign-in cookie marked HttpOnly cannot be read by any script, even a harmful one that slipped onto the page.

Sources: OWASP: HttpOnly; RFC 6265: HTTP State Management Mechanism

Topic: Too much memory, or too little · history, privacy, browsers

Lesson 6: Performance and Lighthouse

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

Topic: What fast means: three numbers · history, browsers, numbers

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

Topic: What fast means: three numbers · numbers, maths

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

Topic: Recording what happened · people, tools, history

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

Topic: Recording what happened · numbers, machines

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

Topic: One worker: the main thread · numbers, standards

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

Topic: One worker: the main thread · history, people, numbers

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

Topic: A full inspection: Lighthouse · numbers, tools

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

Topic: A full inspection: Lighthouse · history, tools

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

Topic: Time it first · history, people, books

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

Topic: Time it first · tools, numbers

Lesson 7: Device mode

Why 320 pixels

Accessibility guidelines give a narrow width to test. WCAG 2.2 asks that content can be used without scrolling in two dimensions at a width equal to 320 CSS pixels. Its note explains the number: 320 CSS pixels is what a window 1280 CSS pixels wide becomes at 400% zoom. So a page that works at 320 serves small phones and people who zoom in alike.

Why it fits here: When you drag the frame narrow, go down to 320 at least: that is the width at which WCAG asks the page to reflow.

Source: W3C: WCAG 2.2

Topic: One screen, any size: the device toolbar · accessibility, standards, numbers

Blue bars and orange bars

The bars of Show media queries have a colour code. The blue bar holds the max-width breakpoints, and the orange bar the min-width ones. Click between breakpoints, and the viewport changes width so that the breakpoint is triggered. Right-click between breakpoints and choose Reveal in source code, and the Sources panel opens at the @media rule.

Why it fits here: It turns this topic's slow drag into a quick check: click each band in turn, and look at the page at each breakpoint.

Source: Chrome for Developers: Simulate mobile devices with device mode

Topic: One screen, any size: the device toolbar · tools, colour

An iPad that says it is a Mac

Some real devices pretend too. With Safari 13 in 2019, WebKit brought a desktop-class browsing experience to the iPad. With the exception of the iPad mini, Safari on iPad began to send a user-agent string identical to Safari on macOS. So a site that checks the user agent sees a Mac, though a finger is touching the screen.

Why it fits here: It is the strongest reason for this topic's rule: ask about the pointer and hover, because the user agent can say Mac on a touch screen.

Source: WebKit: New WebKit Features in Safari 13

Topic: What the pretending changes · browsers, history

Every Android is Android 10

The user agent now tells less than it used to. Under Chrome's User-Agent Reduction, Chrome on Android sends one frozen platform part, Linux; Android 10; K, whatever the phone. The project notes that these strings are literal values, which will not update even on an updated system or device. So a page cannot read the phone's model from the user agent any more.

Why it fits here: It is why this topic asks with hover and pointer queries: the user agent no longer says which phone it is.

Source: The Chromium Projects: User-Agent Reduction

Topic: What the pretending changes · browsers, privacy

How big is a finger?

Standards and guides put numbers on a finger. WCAG 2.2 sets a minimum target size of 24 by 24 CSS pixels at level AA, and an enhanced size of 44 by 44 at level AAA. Google's web.dev recommends around 48 device independent pixels: a 48 by 48 area is about 9 mm, about the size of a finger pad. Targets should also be about 8 pixels apart.

Why it fits here: It is where this topic's 48 pixels comes from, and why the WCAG minimum of 24 is a floor, not a goal.

Sources: W3C: WCAG 2.2; web.dev: Accessible tap targets

Topic: A finger is not a pointer · accessibility, numbers, standards

The inconvenient long tap

Phones do not lack hover by accident. MDN describes hover: none as a primary input that cannot hover at all, or cannot conveniently hover. Many mobile devices, it adds, emulate hovering when the user performs an inconvenient long tap. The Media Queries standard's own example uses @media (hover) to show a hover-activated drop-down menu only on devices that can conveniently hover.

Why it fits here: It is the reason for this topic's rule: on a phone, hover is a bonus, never the only way to reach something.

Sources: MDN: hover; W3C: Media Queries Level 4

Topic: A finger is not a pointer · standards, mistakes

One man in twelve

Colour vision deficiency is common. Colour Blind Awareness puts it at about 1 in 12 men and 1 in 200 women. Wikipedia gives red-green deficiency as 8% of males and 0.5% of females of Northern European descent. To help you see what they see, Chrome 83 added Emulate vision deficiencies to the Rendering tab, with blurred vision among its choices.

Why it fits here: A red-only error message fails about one man in twelve; this topic's emulation shows that failure before a visitor meets it.

Sources: Colour Blind Awareness: About colour blindness; Wikipedia: Color blindness; Chrome for Developers: What's New In DevTools (Chrome 83)

Topic: Other places, other eyes · health, accessibility, numbers

Motion that makes people ill

Reduced motion is a medical need for some people. Apple added a Reduce Motion switch to iOS 7, and in May 2017 WebKit added the prefers-reduced-motion media feature, so that pages can follow it. The WebKit post explains why: the change is required for some people with vestibular disorders. These are caused by problems affecting the inner ear and the parts of the brain that control balance.

Why it fits here: It is why this topic tests the Rendering tab's reduced motion: for some visitors, an animation is not decoration but a cause of sickness.

Source: WebKit: Responsive Design for Motion

Topic: Other places, other eyes · health, accessibility, history

Seven taps

Remote debugging starts with a hidden menu. On an Android phone, Developer options stay hidden until you tap the Build number entry seven times, when the phone says: You are now a developer! There you select Enable USB Debugging. Then, with the phone joined to your laptop by a USB cable, chrome://inspect#devices in Chrome finds it.

Why it fits here: It is the first step of this topic's real-phone test: after it, every panel of this track works on the phone itself.

Sources: Android Developers: Configure on-device developer options; Chrome for Developers: Remote debug Android devices

Topic: Where the pretending stops · tricks, tools

DevTools is a web app

The tool used through this whole track is itself a web app. The repository of the Chrome DevTools frontend says that it contains the client side of Chrome DevTools: all the TypeScript and CSS code that runs the DevTools web app. So the panels you have learnt are built from the same kinds of code as the pages they inspect.

Why it fits here: It closes the track with a thought worth keeping: nothing in DevTools is magic; it is a web app that you could read.

Source: GitHub: ChromeDevTools/devtools-frontend

Topic: Where the pretending stops · tools, browsers