EverProduct
Frontend

Stage 01 · Between the Code and the Screen

The Assembly Line: From URL to Pixels

You typed an address and a page appeared. Between those two events runs a machine with a fixed order of operations — and most of the bugs you'll spend years chasing live at one of its stations.

Press Enter on an address and about half a second later there is a page. Nothing in that half-second is magic, and none of it happens at once.

A machine ran a fixed sequence: find the server, ask for a document, receive text, turn the text into a tree, work out what the tree should look like, calculate where every box goes, fill the boxes with colour, hand the result to the screen. Then it did most of it again, several times, because a script changed something.

Almost everything that will confuse you later — the flash of unstyled text, the script that can't find the button, the page that jumps while you're reading it, the animation that stutters — is this same machine running its stations in the only order it knows. Learn the order once and those stop being mysteries and become addresses.

Three inputs, three different jobs

The browser accepts three kinds of material and does something categorically different with each. Beginners blur them together, and nothing afterwards sits properly until they're separate.

  • HTML is what things are. A heading, a list, a form, a button. Structure and meaning.
  • CSS is what they look like. Size, colour, position, spacing.
  • JavaScript is what happens. Behaviour over time: reacting, changing, fetching.

The test for whether you've really separated them is a question you'll face weekly: should this be done in HTML, CSS or JS? A dropdown that opens on hover — CSS. A dropdown that opens on click and stays open — JS. Text that's a heading — HTML, and no amount of font-size makes a div into one. The wrong choice always works at first and always costs later.

The trip to the server

Your address is a name, and the network only moves numbers. So the browser asks a DNS server which machine example.com is, opens a connection to it, negotiates encryption if the address starts with https, and only then sends the actual request: give me this document.

What comes back is text. Not a page — text, with a status code (200 means here it is, 404 means no such thing, 500 means the server broke) and a set of headers describing what the text is and how long it may be reused.

Two facts from this trip pay off immediately. First, every separate file — every image, stylesheet, script and font — is its own request, and requests cost time even when the files are tiny. Second, the browser caches: much of what feels instant on your second visit was never fetched at all. Which is also why your users see an old version of a file you swear you fixed.

The parser doesn't wait

The HTML arrives as a stream, and the browser starts building before the last byte lands. It reads top to bottom, turning tags into the DOM — a tree of objects, one node per element, nested exactly as your tags were nested.

That tree is not your file. It's a live model built from your file, and from this moment on it's the only thing that exists. Your HTML file is the seed; the DOM is the plant.

Two things interrupt the parser on the way down, and both matter enormously:

A stylesheet blocks rendering. The browser refuses to show a page it doesn't yet know the appearance of, because painting first and restyling after would flash unstyled text in the user's face. So CSS in the head is a gate: nothing is displayed until it arrives.

A classic script blocks parsing. When the parser meets a script tag, it stops building the tree, downloads the file, runs it to completion, and only then resumes. It has to: a script is allowed to write into the document at that exact point. This is the mechanical reason for two rules you'll otherwise memorise blindly — scripts go at the end of the body or carry defer, and a script that runs before the element it needs will fail, because the element genuinely does not exist yet.

Meanwhile the CSS is parsed into its own structure — the CSSOM, the same idea for rules instead of elements.

Layout and paint: where the time goes

Now the browser has two trees and combines them into a render tree: every node that will actually be visible, with its computed styles attached. Elements set to display: none drop out here — they're in the DOM but not in the render tree, which is exactly why they take up no space.

Then the expensive part, in two stations:

Layout (also called reflow) computes geometry: for every box, how wide, how tall, at which coordinates. This is a chain reaction — a paragraph that grows by one line pushes everything below it, which may change the height of a container, which may move a sibling. That's why a small change can be surprisingly costly.

Paint fills in the pixels: backgrounds, borders, text, shadows. Then compositing stacks the layers in the right order and hands them over.

Two practical consequences you will use constantly. Animating something that changes geometry — width, height, top, left — forces layout on every single frame, and at sixty frames per second you have sixteen milliseconds each; that's how stutter is born. Animating transform and opacity doesn't touch layout at all and stays smooth. And an image without declared dimensions has no known height until it arrives, so the browser lays out around a zero-height box and then re-lays-out when the image lands — which is the page jumping under your thumb, on every news site you've ever cursed.

Then the line runs again

The last station isn't the end. The page is now alive and holds a single main thread that does everything: running your scripts, handling clicks, recalculating layout, painting.

Single. There's one of it. Any JavaScript that runs for 300 milliseconds is 300 milliseconds during which nothing scrolls, nothing responds and no animation advances. "The page froze" almost always means one function is doing too much on that thread.

And every time your code changes something visible, the relevant stations run again: change the text of a node and layout and paint rerun for the affected part; change a colour and only paint reruns. You don't have to optimise this on day one. You do have to know that a loop that touches the page a thousand times asks the machine to do the expensive work a thousand times.

You aren't drawing a page. You're feeding a pipeline that will draw one, repeatedly.

Why the map is worth more than the trick

You could write frontend code for months without any of this, copying fixes from answers online. It works right up until something behaves oddly, and then you have nothing to think with — every bug is equally surprising, because you have no model to violate.

The How to Learn sphere calls this the difference between a memorised snapshot and real understanding: one correct angle on a thing is useless the moment the situation shifts, and understanding means being able to change scale — zoom out to the whole pipeline, zoom in to a single station — without losing the object. This article is the zoomed-out view, deliberately taken first. Everything in the next twenty articles attaches to a station on this line: HTML builds the tree, CSS feeds the styles, layout places the boxes, JavaScript edits the whole thing while it's running.

It's also your first chunk in this field. Right now "how a page loads" is nine separate steps you'd have to recite. After a few weeks of use it becomes one block you think with in a single move — and that compression is the only reason experienced developers can hold a whole system in their heads.

In practice

Watch a real page load. Open any large site, open the Network panel of your browser's developer tools, reload, and look at the waterfall. Find the document itself, then the stylesheets, then the scripts, then the images. Ask why the order came out that way. Ten minutes here beats a chapter of reading.

Predict before you look. Before reloading, say out loud what will block what. Then check. Being wrong with a prediction on the table teaches several times more than being told the answer — that's retrieval, not review.

Draw the pipeline from memory. On paper, without the article: request, HTML, DOM, CSSOM, render tree, layout, paint, composite. If a station goes missing, you've found exactly what to reread. Redraw it in three days and again in a week; the How to Learn sphere's spacing rule applies to a diagram as well as to vocabulary.

Classify a page's behaviour into the three inputs. Take a site you use daily and list five things it does: which is HTML, which is CSS, which needs JS? Where you can't tell, you've found the next thing worth learning.

Explain it to someone. Two minutes, out loud, no notes. The explanation collapses at exactly the point your understanding does — which is the cheapest diagnostic in this whole sphere.

Check yourself

Close the article and answer in your own words:

  1. What are the three inputs a browser takes and what is each responsible for?
  2. What is the DOM, and how is it different from your HTML file?
  3. Why does a classic script tag stop the parser, and what follows from that about where scripts go?
  4. What is the difference between layout and paint, and why is one more expensive?
  5. Why does animating left stutter while animating transform doesn't?
  6. What does it mean that the main thread is single, and what does that look like to a user?
  7. Why does an image without declared dimensions make the page jump?

In short

  • Between the address and the pixels runs a fixed sequence: request, HTML into DOM, CSS into CSSOM, render tree, layout, paint, composite.
  • HTML is what things are, CSS is what they look like, JavaScript is what happens — and "which of the three should do this?" is a weekly decision.
  • The parser builds the tree incrementally; stylesheets block rendering and classic scripts block parsing, which is why script placement and defer exist.
  • The render tree contains only what's visible, which is why display: none occupies no space.
  • Layout computes geometry and cascades through the page; paint fills pixels. Animate transform and opacity, not width and left.
  • The page has one main thread for scripts, events, layout and paint — a long function freezes everything.
  • Images without dimensions cause layout shift, because the height is unknown until the file arrives.
  • Learn the map before the tricks: it's the zoomed-out view every later article attaches to, and your first real chunk in this field.