How the DOM Is Rendered

How the Browser Builds and Renders the DOM

Browsers and Engines traced the pipeline from bytes to pixels. The HTML parser tokenizes bytes as they arrive and appends nodes at once, so the top of a long page can paint before the rest downloads. A classic <script> pauses tree construction while a preload scanner fetches upcoming stylesheets, scripts and fonts. When parsing ends and deferred and module scripts have run, document fires DOMContentLoaded; images may still be loading.

Rendering does not draw the DOM directly. Style calculation matches the CSSOM against each element, and the engine builds a separate tree of boxes, the render (layout) tree, which differs in three ways:

The same page as a DOM tree and as a render tree: hidden nodes get no box, pseudo-elements get boxes without nodes
The same page as a DOM tree and as a render tree: hidden nodes get no box, pseudo-elements get boxes without nodes

To ask "does this element have a box?", call element.checkVisibility() (Baseline since March 2024): it returns false for display: none subtrees and content-visibility: hidden, and accepts { opacityProperty: true, visibilityProperty: true } for stricter checks. jsdom 21,691 has no render tree, so its geometry properties return zeros.