{
  "id": 20332033,
  "title": "Your Per-Item ResizeObserver Is a Layout Feedback Loop",
  "url": "https://urgent.news/2026/11/16/your-per-item-resizeobserver-is-a-layout-feedback-loop",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-16T21:26:38.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/robust_true_try/your-per-item-resizeobserver-is-a-layout-feedback-loop-29n1"
  },
  "original_language": "en",
  "account": "Virtualized lists with variable-height rows often encounter a common bug: adding a ResizeObserver to each row for measurement leads to a layout feedback loop, causing the page to fight user scrolling. GitHub's diff-surface rebuild addresses this issue and can be applied to any large list. This article explains how to detect the feedback loop, batch measurements, and anchor height corrections to prevent content movement.\n\nPattern of the feedback loop:\n1. Virtualize a list; each row requires a measured height.\n2. Attach a ResizeObserver per row and write the height into the virtualizer's state.\n3. Measurement triggers layout, which in turn triggers measurement, leading to performance degradation.\n\nTo prevent this:\n1. Separate deterministic elements (fixed-height items) from dynamic blocks (height depends on content, open state, and container width).\n2. Compute deterministic blocks upfront and only measure dynamic blocks when necessary.\n\nKey points:\n1. Use a Set to track dirty blocks containing dynamic heights. Only measure when the fingerprint of changes changes.\n2. Batch measurements using requestIdleCallback and scope the pass to blocks near the viewport.\n3. Apply corrections in a single layout pass to avoid content jumping under the user's cursor.\n4. Anchor corrections to what the user sees by adjusting the scroll offset for blocks above the viewport and letting layouts absorb changes for blocks below.\n5. Provide a synchronous escape hatch for user-initiated dimension changes, such as toggling collapsible sections or opening reply composers.",
  "summary": "Every virtualized list with variable-height rows eventually meets the same bug: you add a ResizeObserver to each row so you can measure it, write the measured height back into your layout state, and the page starts fighting the user's scroll. GitHub's diff-surface rebuild hit exactly this, and their fix generalizes to any large list. By the end you will know how to detect the feedback loop, how…",
  "key_points": [],
  "editors_take": "Batching measurements and separating deterministic elements from dynamic blocks prevents the performance degradation and scrolling instability caused by per-item observers in large, variable-height virtualized lists.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}