skip to content

When a community-board web app's feed has loaded several hundred posts on a phone, why is keeping every post in the page a problem?

level: juniorimportance: should knowfreq 52%

answer

  1. cost follows what is loaded
  2. a post is dozens of elements
  3. every update restyles a bigger tree
  4. memory never comes back
  5. three levers, each with a cost

basics

~20 s

Every loaded post stays as DOM nodes, media and listeners, so memory keeps growing and each update or tap makes the browser restyle and lay out a bigger tree; on a phone that means late taps and janky scrolling.

solid answer

~50 s

The first screen is fast; the trouble grows with the session. A community-board post is dozens of elements — author line, text, gallery or video embed, poll, counts, actions — so a few hundred posts is tens of thousands of nodes, and the reader sees perhaps three of them. A larger DOM makes every later update more expensive: a like, a vote or an appended page can send the browser through style and layout over that whole tree, so taps answer late and interaction latency (INP) climbs. Memory climbs too, because loaded photos, embeds and listeners stay alive for posts nobody will scroll back to. On a mid-range phone that shows up as stutter and, in long sessions, can end in a tab that runs out of memory. The fixes are design choices — `content-visibility: auto`, windowing, or paging with a ceiling — and each has its own cost.

go deeper

for a junior

Recall that every loaded post stays in the DOM, so memory and the cost of each update grow with the session. Name the three levers: content-visibility, windowing and paging.

for a middle

Explain why a tap on post 250 is slower than on post 5: the style and layout work an update triggers grows with the tree, and nothing loaded is ever released.

for a senior

Turn the symptom into a measurement plan on a low-end phone and a budget for loaded posts, then pick the lever whose cost the product can carry.

for a principal

Treat feed length as a product property: long mobile sessions are the norm, so the team needs a node and memory budget, not a one-off optimisation.

## What "several hundred posts" means to the browser A post on a neighbourhood community board is not one element. It has an author line with an avatar, a timestamp, the text, often a photo gallery or an embedded video, sometimes an event card with an **RSVP** button or a poll with its options, like and comment counts, and a row of actions. Depending on its type, one post is anywhere from a few dozen to over a hundred elements. Two hundred posts is therefore tens of thousands of elements — and a reader who keeps scrolling never stops adding to it. The **DOM** (Document Object Model) is the browser's live tree of the page. The work of drawing the page — matching CSS rules to elements (**style**), computing every box's size and position (**layout**) and drawing pixels (**paint**) — runs over that tree. As a general rule, the larger the DOM, the more expensive both the first render and every later update become. Widely used performance audits start warning at around 800 DOM nodes and call about 1,400 excessive; a long feed passes that inside its first page. ## Where the cost lands | Cost | When it bites | What the reader feels | |---|---|---| | Style and layout on each update | a like, a vote, a new page appended | taps that answer late; poor Interaction to Next Paint (INP) | | Memory held by nodes | grows with every page loaded | a slower and slower tab on a low-memory phone | | Media held by old posts | loaded photos and video embeds stay in the page | heavier scrolling, more battery | | Scripts that query the DOM | code that selects many elements | more references held in memory | The second row is the one interviewers care about most. When an interaction inserts, removes or restyles nodes, the browser may have to redo style and layout work whose scope grows with the tree. A like button that answered instantly on post 5 can answer late on post 250, with no extra network delay at all. ## Why it gets worse the longer someone reads - **Cost follows what is loaded, not what is visible.** The reader 200 posts deep sees three posts; the page carries all 200. - **Appending is not free.** Page ten is inserted into a tree that already holds nine pages, so each append costs more than the last. - **The browser does not skip off-screen posts by itself.** Off-screen posts still take part in style and layout unless the page opts out, which is exactly what `content-visibility: auto` asks for. - **Phones have the least headroom.** Slower cores and less memory turn a cost a laptop hides into stutter and a tab that runs out of memory. - **Mobile readers scroll far.** A community feed is a browsing surface; long sessions are the normal case, not the edge. ## The three levers Recognising the problem is the junior half; choosing the fix is the design half. There are three standard levers: 1. **`content-visibility: auto`** with a `contain-intrinsic-size` estimate: the browser skips rendering work for posts that are off screen, but the posts stay in the DOM — so node count and memory still grow, while find-in-page and screen readers keep working. 2. **Windowing** (also called virtualisation): only the posts near the viewport exist as DOM nodes; spacers keep the scrollbar honest. The DOM stays small no matter how far the reader goes, at the price of knowing item heights and of hiding unrendered posts from find-in-page and assistive technology. 3. **Paging with a ceiling**: numbered pages, or dropping pages far behind the reader. Simple and bounded, at the cost of the continuous-scroll model or of reloading what the reader returns to. None of them is free, which is why "which one, and what does it cost" is the follow-up that comes next in a design round. ## What a strong short answer contains - The cost scales with the session, so measuring only the first screen hides it. - Updates and taps get slower, not just the initial load. - Memory grows because nothing is ever released. - Image lazy-loading defers downloads but leaves every node in place, so it does not fix this. - A list key helps the framework match rows; it does not reduce how many rows exist. Saying all five in a minute, then naming the three levers, is a complete answer at this level.

  • Would you window a community board's 'pinned posts' list that never holds more than about 20 items?
    No. Twenty posts is a small, bounded DOM, so windowing would add height bookkeeping and accessibility gaps for no measurable gain. The problem is unbounded growth across a session, which a short pinned list does not have. Revisit only if a measurement on a low-end phone shows it is slow.
  • How would you show the team that the feed's slowdown comes from DOM size and not from the network?
    Scroll to post 300 on a mid-range phone and compare a tap on a like button there with the same tap on post 5. If the delay grows while the request time does not, the main thread is doing more work per update. A count of DOM elements at both points makes the link visible.

  • The browser already skips style and layout for posts that are off screen.
  • Lazy-loading the images fixes a long feed's slowdown.
  • Only the first render matters; later appends are cheap.
  • Giving every post a stable key reduces the number of DOM nodes.
  • It only matters on desktop, where lists get longest.