Browser internals: DOM, rendering pipeline and critical path – Front End interview prep
261 interview-style multiple-choice questions on Browser internals: DOM, rendering pipeline and critical path, organized by topic: concepts, scenarios, code to read and tradeoffs, each with a short explanation. Learn the 51 key terms with the flashcards first, then test yourself.
Take the practice test · Flashcards · All study tools
What it covers
- 9.1 The DOM and DOM APIs
- 9.2 Events and event handling
- 9.3 The rendering pipeline
- 9.4 Loading, parsing and the critical path
- 9.5 Storage, cookies and browser caching
- 9.6 Networking, origins and fetch
- 9.7 Browser architecture and the security model
- 9.8 Web platform APIs: observers, history and more
- 9.9 DevTools and debugging in the browser
Key terms
9.1 The DOM and DOM APIs
- Live collection
- DOM list that updates as the document changes
- DocumentFragment
- Lightweight container for building nodes off-DOM
- Custom element
- Developer-defined HTML tag
- Declarative shadow DOM
- Shadow roots created from HTML templates
9.2 Events and event handling
- DOM
- Document Object Model: the tree of objects representing the page
- Event bubbling
- An event travelling from the target up through its ancestors
- Event delegation
- One listener on an ancestor handling events from many descendants
- Shadow DOM
- Encapsulated DOM subtree with its own scoped styles
- Pointer Events
- Unified mouse, touch and pen input events
- CustomEvent
- Script-created event carrying detail data
- isTrusted
- Flag showing an event came from the user
9.3 The rendering pipeline
- Render tree
- The visible DOM nodes combined with their computed styles
- Layout (reflow)
- Computing the size and position of every box
- Paint
- Filling in pixels for text, colors, borders and images
- Compositing
- Combining painted layers into the final image, often on the GPU
- Style recalculation
- Matching CSS rules to elements
- Stacking context
- Group that z-index compares within
- Compositor thread
- Thread that combines layers and can scroll
- Jank
- Visible stutter from slow frames
9.4 Loading, parsing and the critical path
- Render-blocking resource
- A file that must load before the browser can paint, typically CSS and synchronous scripts
- defer
- Script attribute: download in parallel, run in order after parsing
- async
- Script attribute: download in parallel, run as soon as ready
- Preload
- A hint to fetch a needed resource early at high priority
- Preload scanner
- Look-ahead parser that starts fetches early
- Parser-blocking script
- Script that halts HTML parsing until it runs
- Speculation Rules
- JSON rules to prefetch or prerender pages
- Import map
- Maps bare module specifiers to URLs
9.5 Storage, cookies and browser caching
- Same-origin policy
- Browser rule that stops scripts reading data from another origin without permission
- Service worker
- Background script that can intercept requests for offline support and caching
- ETag
- Response version identifier used to revalidate cached content
- IndexedDB
- Browser database for large, structured data with async access
- Cache Storage
- Script-managed store of request/response pairs
- OPFS
- Origin Private File System for web apps
- Storage partitioning
- Third-party storage keyed by top-level site
- CHIPS
- Partitioned third-party cookies
9.6 Networking, origins and fetch
- Origin
- Scheme, host and port together
- Site
- Scheme plus registrable domain
- Opaque response
- Cross-origin response hidden from script
- sendBeacon
- Fire-and-forget POST for page exit
9.7 Browser architecture and the security model
- Blink
- Chromium's rendering engine
- Site Isolation
- Separate renderer processes per site
- JIT compiler
- Compiles hot JS to machine code at runtime
- Browsing context
- Environment showing a document
9.8 Web platform APIs: observers, history and more
- Navigation API
- Single API for intercepting navigations
- Secure context
- HTTPS or localhost page
- WebAssembly
- Binary format running near native speed
- Web App Manifest
- JSON describing an installable app
9.9 DevTools and debugging in the browser
- Conditional breakpoint
- Pauses only when an expression is true
- Logpoint
- Breakpoint that logs without pausing
- Heap snapshot
- Memory picture with retainer paths
- Detached DOM node
- Removed node still referenced by JS
Sample practice questions
What is the DOM?
- The tree of objects built from HTML that scripts read and change
- The CSS rules for each element, merged into one stylesheet
- A copy of the page kept on the server for search engines
- The raw HTML text exactly as the server sent it over the network
Answer: A. The tree of objects built from HTML that scripts read and change Changing the DOM changes what is rendered; the source HTML stays the same.
In which order do event phases happen when you click a nested `<button>`?
- Only the target phase; events never visit ancestors
- Bubbling up to the window first, then capture back down
- Capture down to the target, the target, then bubbling back up
- Capture and bubbling run at the same time on every ancestor
Answer: C. Capture down to the target, the target, then bubbling back up Listeners run in the bubbling phase by default; pass `{ capture: true }` to listen while capturing.
In what order does the browser turn HTML and CSS into pixels?
- Composite layers first, then build the DOM and paint
- Download images, parse CSS, build the DOM, then layout
- Paint first, then layout, then parse the HTML and CSS
- DOM and CSSOM, render tree, layout, paint, then composite
Answer: D. DOM and CSSOM, render tree, layout, paint, then composite Each step can be the bottleneck; changes late in the pipeline are cheaper.
What is the difference between `DOMContentLoaded` and `load`?
- The first fires after parsing; `load` also waits for images and styles
- `DOMContentLoaded` waits for every image to download first
- They always fire at the same moment on every page
- `load` fires first, before the HTML has been parsed
Answer: A. The first fires after parsing; `load` also waits for images and styles Most setup code only needs the DOM, so it can run at `DOMContentLoaded`.
What are the main differences between `localStorage` and `sessionStorage`?
- `localStorage` persists until cleared; `sessionStorage` lasts for the tab
- `localStorage` is sent to the server with every request
- `sessionStorage` can store files; `localStorage` can only store text
- `sessionStorage` is shared across all tabs; `localStorage` is per tab
Answer: A. `localStorage` persists until cleared; `sessionStorage` lasts for the tab Both are synchronous and limited to a few MB; use IndexedDB for larger or structured data.
What does the same-origin policy restrict?
- Using more than one domain in a single page
- Loading any image from another domain into a page
- Opening links that point to other websites
- Scripts reading data from another origin unless it allows it (CORS)
Answer: D. Scripts reading data from another origin unless it allows it (CORS) Embedding cross-origin images and scripts is allowed; reading their contents from script is not.
What's a rendering engine?
- A GPU driver installed with the browser
- The browser's network stack for HTTP requests
- The part of a browser that runs JavaScript only
- The part of a browser that turns HTML and CSS into pixels
Answer: D. The part of a browser that turns HTML and CSS into pixels Examples are Blink, WebKit and Gecko.
What is a service worker?
- A background script that can intercept requests, enabling offline use
- A server-side process that generates and serves the HTML
- A web worker whose job is to render the DOM off the main thread
- A browser extension API for blocking network requests
Answer: A. A background script that can intercept requests, enabling offline use It only works over HTTPS (or localhost) and has its own lifecycle.
Which DevTools panel shows the live DOM and its styles?
- Application
- Elements
- Sources
- Network
Answer: B. Elements Firefox calls it the Inspector.
What is the Shadow DOM used for?
- Rendering the page in the background before showing it
- Storing a hidden copy of the DOM for undo and redo
- Speeding up `querySelector` calls on very large pages
- Encapsulating a component's DOM and styles from the page
Answer: D. Encapsulating a component's DOM and styles from the page Web Components use Shadow DOM for style isolation.
More Front End
- HTML semantics & accessibility
- CSS: box model, Flexbox, Grid
- JavaScript fundamentals
- Async JavaScript & the event loop
- TypeScript
- React: components, hooks & rendering
- State management: Redux, Zustand, context
- Angular and Vue basics
- Web performance
- Build tools & bundlers
- Front-end testing
- Front-end security
- Mobile & cross-platform