Skip to the page

Web platform · 17 concepts

DOM and the browser

Events, rendering, storage, observers and workers: how the browser really works under your framework.

Part 1 · 4 concepts

The DOM and events

  1. 01

    The DOM tree and building UI with plain DOM APIs

    The DOM is a tree of node objects the browser builds from HTML; you query it (querySelector), create nodes (createElement, textContent), and insert them in batches…

  2. 02

    Event flow: capture, target, bubble

    An event travels down from window to the target (capture), fires on the target, then bubbles back up; stopPropagation stops the travel, stopImmediatePropagation also…

  3. 03

    Event delegation

    Delegation puts one listener on a parent and uses event.target.closest() to find which child was hit, so it works for many items and for items added later.

  4. 04

    Listener options, removing listeners and custom events

    addEventListener options (once, passive, capture, signal) control how a listener behaves; an AbortController signal removes many listeners at once; CustomEvent lets…

Part 2 · 5 concepts

How the browser draws the page

  1. 05

    What happens when you type a URL

    The browser resolves DNS, opens a TCP (or QUIC) connection with TLS, sends an HTTP request, then parses HTML into the DOM, CSS into the CSSOM, runs scripts, and…

  2. 06

    Style, layout, paint and composite

    Changing layout properties (width, top) re-runs layout and paint; changing paint-only properties (color) re-runs paint; changing transform or opacity can skip both and…

  3. 07

    Layout thrashing and batching DOM work

    Reading a layout value (offsetHeight, getBoundingClientRect) right after a style write forces the browser to do layout immediately; doing read-write-read-write in a…

  4. 08

    requestAnimationFrame, requestIdleCallback and timers

    requestAnimationFrame runs your callback right before the next paint (about 60 or 120 times a second, paused in hidden tabs), so it is for visual updates…

  5. 09

    Script loading: async, defer, module

    A classic <script> blocks HTML parsing while it downloads and runs; defer downloads in parallel and runs in order after parsing (before DOMContentLoaded); async runs as…

Part 3 · 2 concepts

Storage and fetching

  1. 10

    Cookies, localStorage, sessionStorage, IndexedDB and Cache

    Cookies are small and sent with every request (use them for sessions, with HttpOnly, Secure, SameSite); localStorage persists per origin, sessionStorage per tab; both…

  2. 11

    fetch in depth: errors, AbortController and timeouts

    fetch only rejects on network failure, not on 404 or 500, so check response.ok; AbortController cancels a request (and is how you fix race conditions in search), and…

Part 4 · 6 concepts

Observers, workers and the platform

  1. 12

    IntersectionObserver: lazy loading and infinite scroll

    IntersectionObserver tells you asynchronously when an element enters or leaves the viewport (or a root), so you can lazy-load images and load the next page when a…

  2. 13

    ResizeObserver and MutationObserver

    ResizeObserver reports element size changes (for components that adapt to their own width), and MutationObserver reports DOM changes (added nodes, attributes); both…

  3. 14

    Web Workers, Service Workers and messaging

    A Web Worker runs JavaScript on another thread for heavy work (no DOM); a Service Worker is a proxy between the page and the network for offline and caching; they talk…

  4. 15

    History API and client-side routing

    Client routers change the URL with history.pushState (no reload) and react to back/forward through the popstate event; the server must return the app for every route so…

  5. 16

    Memory leaks in the browser

    A leak is memory still reachable that you no longer need: listeners and timers never removed, detached DOM nodes held by JavaScript, growing caches and closures; find…

  6. 17

    Web components and Shadow DOM

    Custom elements (customElements.define) plus Shadow DOM give framework-free components with encapsulated styles; they are used for design systems shared across…

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview