Frontend Debugging

Reproduce, then work the layers: network, console, DOM and CSS, application state, performance, memory. A method, not a tour of a devtools panel.

A Method for Frontend Bugs
▶ lab

Reproduce, work the layers in order, narrow by bisection, fix, and then prove the signal moved. The method is the skill; the panels are interchangeable.

Q · How do I get from "it is broken for some users" to a fix I can show actually changed the thing that was broken?
A Mental Model of the Devtools
▶ lab

Seven panels, seven questions. Learn which question each one answers and what it structurally cannot tell you, and the UI can change underneath you without costing you anything.

Q · Which question does each devtools panel actually answer, and what is that panel incapable of telling me?
Debugging the Network
▶ lab

Read the waterfall for its shape, not its totals. Then learn the three ways the network panel lies: the CORS error that is a 500, the cache row that is not a hit, and the request that is missing because a service worker answered it.

Q · What did the browser actually request, in what order, what was each request waiting for, and where did the response really come from?
Debugging Rendering and Jank
▶ lab

Separate a frame that took too long from a frame that was never attempted, then find which pipeline stage the change is actually costing — with the forced-layout warning, paint flashing and layer borders as your three cheapest instruments.

Q · This feels janky — is the browser doing too much rendering work, or is something else holding the thread it renders on?
Debugging State
▶ lab

A wrong value on screen is the end of a sequence, not a snapshot. Reconstruct the transitions, then answer the question that resolves most of these bugs: which copy of this data is authoritative?

Q · The data on screen is wrong — which copy of it is authoritative, and what sequence of events produced the one I am looking at?
Debugging Memory
▶ lab

Three snapshots across a repeated cycle, then follow the retainer chain to whatever is holding the thing that should have gone. Growth is not a leak until you can say what is keeping it alive.

Q · Memory keeps climbing in this tab — is something leaking, or is a cache doing exactly what it was asked to do?