skip to content

For a community-board web app's mixed home feed on phones, would you window it, use content-visibility, or plain pages, and at what cost?

level: middleimportance: must knowfreq 72%

answer

  1. rendering cost versus node count
  2. content-visibility keeps find-in-page
  3. windowing needs heights and focus care
  4. set a ceiling from a low-end phone
  5. window by page, not only by row

basics

~20 s

Start with appended pages and content-visibility: auto, which skips rendering off-screen posts yet keeps them findable and readable by screen readers; it does not cap memory, so past a measured ceiling, window or drop far pages.

solid answer

~40 s

I'd decide on three costs: rendering work, node count and memory, and what the reader loses. `content-visibility: auto` on each post, with `contain-intrinsic-size: auto <estimate>`, cuts rendering work for off-screen posts while they stay in the DOM and the accessibility tree, so find-in-page, focus and screen readers keep working and mixed heights need no bookkeeping. It does not reduce nodes or memory. Full windowing keeps the DOM small for any session length, but I then own item heights, scroll correction, focus and the feed's ARIA, and find-in-page only sees rendered posts. Numbered pages are simplest and bounded, but they break the browsing model a community feed is built on. So: content-visibility first, then a ceiling measured on a low-end phone, past which far pages are removed and replaced by spacers of their measured height.

code

css · 10 lines
css
.post {
  content-visibility: auto;
  contain-intrinsic-size: auto 420px;
}
.post--text {
  contain-intrinsic-size: auto 180px;
}
.post--event {
  contain-intrinsic-size: auto 260px;
}

go deeper

for a junior

Know the three levers: plain pages, content-visibility, windowing. Recall that only windowing removes off-screen posts from the DOM.

for a middle

Compare the levers on rendering cost, node count, memory and reader tools, and explain why content-visibility saves rendering work but not nodes or memory.

for a senior

Propose a staged design with a ceiling measured on a weak phone, and say what the team must own once it windows: heights, scroll correction, focus and the feed's ARIA.

for a principal

Frame the choice as which cost the product carries and who maintains it; prefer the lever whose failure modes the team can test and own.

## The decision in one sentence A community-board home feed mixes text posts, photo galleries, event cards, polls and video embeds, is read mostly on phones, and is often scrolled two hundred items deep. The design question is not "should we optimise" but **which cost the product can carry**: rendering work, DOM size and memory, the reader's tools (find-in-page, screen readers, keyboard focus), and engineering effort. ## The three levers **Plain pages.** The feed shows a fixed number of posts per page with numbered page links or a "Next page" link. The DOM is bounded by construction, Back returns to a real URL, and nothing is clever. The cost is the browsing model: a neighbourhood feed is skimmed continuously, and tapping "Next" every twenty posts on a phone is friction the product team will reject. **`content-visibility: auto`.** A CSS property that tells the browser it may skip rendering work for an element's contents while that element is not relevant to the user, typically off screen. The skipped posts **remain in the DOM and the accessibility tree**, stay available to find-in-page and remain focusable. It needs a companion: under size containment a skipped post lays out as if it were empty, so without a size the scrollbar jumps as posts render. `contain-intrinsic-size: auto 400px` gives an estimate, and the `auto` keyword makes the browser remember each post's last rendered size. **Windowing (virtualisation).** Only the posts in and near the viewport exist as DOM nodes; spacers above and below hold the scroll height. The DOM stays small however long the session runs. The page now owns what the browser used to do: an estimate and a measurement for every post's height, scroll correction when a measured height differs, keeping a focused post alive, and telling assistive technology each post's position. ## What each costs | | Plain pages | content-visibility | Windowing | |---|---|---|---| | Rendering work for off-screen posts | current page's posts only | skipped | none (not in DOM) | | DOM size and memory | bounded per page | grows with session | bounded | | Mixed item heights | free | estimate, browser corrects | page measures and corrects | | Find-in-page | current page only | all loaded posts | rendered posts only | | Screen readers and focus | normal | normal | needs the feed pattern and focus pinning | | Back to the same place | easy (a URL) | the page restores loaded posts | the page restores window and heights | | Effort | lowest | low | highest | Two misreadings are common. `content-visibility` is not windowing: it saves rendering work, not nodes, so memory keeps rising. And windowing is not free accessibility-wise: an unrendered post is invisible to find-in-page and to a screen reader's reading mode until something renders it. ## The design I would propose 1. **Append pages and put `content-visibility: auto` on each post**, with `contain-intrinsic-size: auto` and a per-type estimate (a text post, a gallery, an event card). This removes most rendering cost and keeps every reader tool working. 2. **Make heavy media cheap when off screen**: video embeds load as a poster with a play control, and a playing video pauses when it leaves the viewport. 3. **Set a ceiling by measurement**, not by guess: on a low-end phone, find how many loaded posts the tab carries before taps slow or memory climbs past a budget. 4. **Past the ceiling, window by page**: remove pages far behind the reader and replace each with a spacer of its measured height, keeping ids, data and cursor so the page can be rendered again on the way back. Windowing by page keeps the DOM bounded while the posts near the reader — the ones find-in-page and a screen reader are actually used on — stay real. Row-level windowing is usually the better fit when the item count is huge from the start (a list of thousands that loads at once), not for a feed that grows by pages. ## When the answer changes - **Thousands of uniform rows up front** (a members directory): row windowing with fixed heights is cheap and clearly worth it. - **Short sessions** (a feed most people read ten posts of): content-visibility alone, no ceiling needed. - **A need for stable, shareable positions** (an archive of meeting minutes): numbered pages win. - **A team without capacity to own focus and ARIA**: prefer the levers that keep posts in the DOM. ## What interviewers listen for - Separating rendering cost from node count and memory. - Knowing that `content-visibility` keeps posts in the accessibility tree and find-in-page, and that windowing removes them. - A ceiling backed by a measurement on a weak device. - Naming what the chosen lever costs, not only what it saves.

  • Why window the feed by page rather than by individual post once you pass the ceiling?
    Removing whole pages far behind the reader replaces many posts with one spacer whose height is already measured, so the scroll math is simple and the posts near the reader stay real for find-in-page, focus and screen readers. Row-level windowing bounds the DOM more tightly but makes the page own every post's height and the full ARIA contract.
  • How would you pick the ceiling past which the feed starts removing far pages?
    Load the feed on the weakest phone the audience commonly uses, scroll in steps of fifty posts, and record tap-to-paint delay and memory at each step. The ceiling is the post count just before either crosses the team's budget, with margin for heavier post types. Re-measure when new post types ship.
  • The product team wants the feed to feel infinite but also wants the footer links reachable. How do you reconcile those?
    Either move the footer's links into a menu or sidebar the feed never pushes away, or switch the feed to a 'Load more' button after a few automatic pages so the reader can reach the end of the document. Both keep the continuous browse while avoiding a footer the reader can never scroll to.

  • content-visibility removes off-screen posts from the DOM, like windowing does.
  • content-visibility hides off-screen posts from screen readers and find-in-page.
  • Windowing has no accessibility cost because only off-screen posts are removed.
  • Mixed post heights make content-visibility unusable for a feed.
  • Window every list from the start, whatever its size or session length.