jz.
Let’s talk ↗
↖ THE NOTEBOOK

BUILD NOTE 01 / INTERFACE ENGINEERING

A rendering budget
for large diffs.

A ten-thousand-line file is a data problem. The browser only needs to paint a small part of it.

JIAHANG ZHANG2 MIN READRSS ↗

Start with the viewport

A code review interface can receive a large file while showing only a few dozen lines. That difference is the useful constraint. The file belongs in the data model; the viewport determines how much of it needs a visual representation at any moment.

This is the starting point of react-virtualized-diff, a React component for reviewing large text changes. It combines virtual scrolling with split or unified layouts and collapsible unchanged context. The goal is to keep a familiar review experience as the input grows.

Two budgets, two decisions

Comparison and presentation have different costs. A diff algorithm still needs to establish what changed. Virtualization limits the DOM and layout work that comes afterward. Optimizing one does not automatically resolve the other.

Collapsing unchanged regions is another useful decision. It reduces the amount of material a reviewer has to scan. Expanding context should remain an explicit interaction, so the user can inspect the surrounding lines when the change needs more explanation.

THE WORKING RULE

Keep the full comparison available. Spend rendering work where the reader is looking.

Performance still needs a usable API

A component has to fit into an existing product. It needs controlled inputs, a bounded viewport, a way to choose the layout, and styling hooks that can follow the surrounding interface. The portfolio demo uses the published component directly:

import { DiffViewer } from 'react-virtualized-diff';

<DiffViewer
  original={before}
  modified={after}
  height={320}
  splitView={true}
  showDiffOnly={true}
  contextLines={2}
/>

Those options describe decisions a product team can make: how much space the review occupies, how changes are arranged, and how much unchanged context is initially visible. The component can then manage the rendered list within that space.

Try the boundaries

The interactive playground lets you switch between 120 and 10,000 generated lines, change layouts, and expand unchanged context. The sample text is generated; the published library performs the rendering.

Useful checks include reaching the end of a long file, changing the layout after scrolling, resizing the viewport, and reviewing in both themes. A small example is a quick introduction. Large inputs and awkward transitions reveal whether the interaction holds together.

The project also includes a separate benchmark harness. Its report records the test environment and comparison cases; the playground here is an interactive component demonstration.

Follow the thread

Project source and API ↗Benchmark methodology and results ↗
KEEP EXPLORINGThe project behind this note