Town 02 · Browser
The window district
Five residents who turn a web address into pixels on your screen, each with one job in the chain. Meet them in the order they work.
Step 1 · Network
The postmaster
Every page starts as a letter. She looks up the address, carries the request to the server, and brings back the HTML, then goes out again for every image, stylesheet and script it asks for.
The ideaFetching every request
Step 2 · HTML parser
The parser
She reads the HTML one tag at a time and hangs each one on a branch of a growing tree. When she reaches a script, she stops and waits for it to run before reading on.
The ideaTurning text into a tree (the DOM)
Step 3 · Layout
The architect
Given the tree and the stylesheets, he measures every box: how wide, how tall, and exactly where it sits. Make one box wider and he has to measure its neighbours again.
The ideaWorking out where every box goes
Step 4 · Paint & compositing
The painter
She paints the page on separate sheets of glass, then stacks them. When something scrolls or fades, she slides one sheet instead of painting it all again.
The ideaDrawing in layers, then stacking them
Step 5 · JavaScript engine
The translator
He reads every script aloud the first time. When the same lines keep coming back, he rewrites them in the machine’s own language, so they run much faster from then on.
The ideaRunning scripts, and getting faster the more it sees one