On mobile it kinda does. Scrolling diffs on mobile just kinda feels crap.
I have been spoiled by years of engineer hours spent getting scrolling to be 60- or even 120Hz smooth to match my finger, and diffs just.. isn't.
I know this is frustrating to hear, and that this is technically compounded by mobile probably having the lowest device performance to be playing with too, but.. There you go.
(I say this, having done a vibe-port of the code to a browser extension, so the underlying concept works.)
document.getElementsByTagName('main')[0].style.margin = '0 auto';IMO (as someone who doesn't have to deal with the actual rendering) it would go a bit deeper into talking about deciding how to show what has changed. There's a lot of improvements that could be made there. e.g. "whitespace has changed here" so there's no real code changes involved.
Or "this big list of imports has changed, and code formatting has line-wrapped the list into different lines" - gitlab for example copes poorly with this. I'd love to just see a clean diff that highlights the additional import, and not just ten lines of changes caused by adding one line to a big list of imported symbols/functions.
something i'd really want to see from forges is alternate diff techniques: like AST diffing.
However passing a million lines of code through pretext is unlikely to be very efficient, so a lot of the work around estimation is still very important.
That said, while I don't want to make pretext a direct dependency of the library, there's a good chance I'll explore the possibility of allowing devs to pass it in as an additional argument perhaps improve performance a bit.
It should also be noted that we have a full API to support things like line annotations (comments, etc) that are entirely controlled by the user, so there's always a bit of a dynamic aspect there that would come into play
That said though, and maybe I didn't say it well in the post, the more performant and optimized your tool is, the less burden you put on developers and users.
Sure you won't review 100k lines, but maybe the diff includes a ton of testing snapshots, or maybe it's a long running feature branch and you need to just quickly jump in and look at a specific change from a specific file. The less the developer or the user needs to think about `how` to render the diff or `how to navigate the diff`, the better we did our job.
Any views they have on this topic is going to come across as quite opinionated given their choices for text rendering for this post and general aesthetics of website.
Posted on May 29, 2026 by @amadeus
βββββββ βββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββ
βββββββββββ βββ ββββββββββββ ββββββ ββββββββ βββββββββββ βββ ββββββββββββ ββββββ ββββββββ ββββββββββββββ βββ ββββββββ βββββββ ββββββ βββ ββββββββ
βββ βββββββ βββββββββββββββββββββββββββ
βββ βββββββββββββββββββββββββββββββββββ
βββββββββββ βββ ββββββββββββ ββββββ ββββββββ βββββββββββ βββ ββββββββββββ ββββββ ββββββββ βββ ββββββββββββββ βββ ββββββββ βββ βββββββ ββββββ βββ ββββββββ
You open a pull request expecting to understand what changed.
For small and medium changes, everything works. The code is readable, the files are there, you scroll around, add comments, and itβs all pretty seamless.
Then you open something larger. Maybe an agent generated the implementation, tests, fixtures, and snapshots. Maybe the branch just touched more files than expected. Either way, the review surface starts to degrade. It might only show you one file at a time, or require each file to be loaded separately before you can read it, or even make basic navigation feel sluggish.
Some of these are reasonable trade-offs for genuinely hard problems. But they still have a cost: reviewers feel the limits of the tool, and product teams have to build workarounds for these limits.
Diff rendering matters, but for most tools it is not the product. The product is what happens around the code: review workflows, automation, agent output, CI results, and collaboration. Code review should support that work, not become something every team has to build from scratch.
That is why, about 6 months ago, we released Diffs. Our goal was to make the code and diff rendering part just work, so teams could spend their time on the product around it.
Originally we launched with just the basic pieces: File and FileDiff components. We quickly got feedback about performance issues, so we followed up with a simple virtualizer that avoided rendering code when it was out of view and an API to move syntax highlighting into worker threads. The simple virtualizer helped, but it was a stopgap. There was still a lot of O(nΓm) complexity, high memory usage, and virtualization blanking. What was missing was a higher-level component that could manage an entire review surface and handle the hard problems related to scale.
That missing layer became CodeView: a virtualization-first component for reviewing code and diffs. And we built it around a deliberately impossible goal:
You should be able to just render any diff.
Not literally, of course. There are physical limits to browsers, compute, and memory. But practically speaking, I think weβve come pretty close, and Iβd like to share a bit about how we got there.
If you find long-form blog posts boring, go check out the CodeView playground at DiffsHub.com where you can pretty much view any PR or diff that GitHub will send our way. Nearly any diff, at any scale, nearly instantly.
diffshub[dot]com
Take any public diff from GitHub and virtualize it nearly instantly, no matter how large, with DiffsHub. Built to show off our brand new CodeView component.
To try it out, replace `github` with `diffshub` in your address bar. pic.twitter.com/5X30YwbpHn
β Pierre (@pierrecomputer) May 20, 2026
You can check out the CodeView component and more in the latest version of the diffs package on npm: @pierre/diffs, or read the docs.
On the surface, rendering diffs in a browser may not seem very hard. Itβs just text, right? Browsers are purpose-built to take raw HTML and turn that into something you can look at and interact with. Code is just text, after all.
But a good review surface needs more than text. It needs syntax highlighting, line numbers, annotations, comments, theming, split and unified layouts, wrapping modes, and enough customization to fit into someone elseβs product. Each of those features adds cost and complexity. Syntax highlighting adds processing time and inflates DOM count. Comments involve additional layout complexity that we canβt fully control, and they still have to work seamlessly with your existing design system.
With CodeView, we take that per-file complexity and scale it up; work that was cheap for a single diff now has meaningful cost across a large review. We can roughly break down the problems into three categories:
Our simple virtualizer helped with some rendering problems, and moving highlighting off the main thread helped with parts of the processing problem. But CodeView needed to treat rendering, memory, and processing as connected parts of the same problem.
Virtualization, or windowing, is a way of tackling the rendering problem. In its simplest form, the idea is to only render the part of the content near the viewport. As you scroll, the virtualizer renders the new content coming into view and removes content that has moved off screen.
Keeping the DOM small has a lot of benefits: lower memory usage, less layout work, less paint work, and fewer elements for the browser to manage. The trade-off is that the virtualizer has to estimate or measure how tall everything is, and it must coordinate those changes dynamically.
One thing that adds to this complexity is that browsers generally manage scroll compositing separately from JavaScript execution. This can help scrolling feel more responsive to user interactions, but it also means that JavaScript can easily lag behind scroll updates. This is often most noticeable when using the scrollbar to make large jumps or scrolling extremely quicklyβββthe virtualizer canβt keep up and youβll scroll into blank regions before the JavaScript has time to render the updated content.
Click to see blanking in the old virtualizer
There are a few common ways to virtualize content in a browser, and each comes with its own set of trade-offs.
The most common approach is to create a real scrollable region with the full estimated height of the content, then position the visible items where they belong. This keeps scrolling native: the scrollbar, momentum, input handling, and accessibility all stay with the browser. The trade-off is that the rendered window can fall behind the visual scroll position. Fast scrolls and large scrollbar jumps can expose blank space before JavaScript has a chance to render the next range. You can reduce that by rendering a larger buffer outside the viewport, but that gives back some of the DOM, layout, and memory savings that virtualization was supposed to buy you.
Another approach is to keep the visible content in a sticky or fixed container and update what it shows with requestAnimationFrame. In this model, blanking is impossible: the content container cannot scroll out of view because itβs not moving with the scroll position; it just looks like it is. However, if JavaScript cannot keep up, then scrolling can hitch or stutter because JavaScript is now part of the render update path. Browser behavior matters here too. Safari, for example, currently caps requestAnimationFrame at 60Hz even on higher refresh-rate displays, which makes this approach feel worse than native scrolling on those devices.
A more extreme version is to emulate scrolling entirely: no native scrollable region, just a custom viewport, a fake scrollbar, and content updated via requestAnimationFrame as the user moves through the document. This can avoid browser scroll-size limits because the scroll position is now your own state, not the browserβs. But the cost is larger: you now own the details of making scrolling feel native, accessible, and correct across different operating systems and browsers.
For CodeView, many of those virtualization trade-offs were not acceptable. Native browser scrolling mattered. WebKit-based environments needed to feel good because Tauri is a common target for developer tools. And blanking was not an option.
This left us stuck between different approaches that werenβt quite right. After some experimentation and frustration, we figured out a hybrid approach that could keep scrolling native, mostly decouple positioning from requestAnimationFrame updates, and make blanking effectively impossible.
Weβve called our new technique the Inverse Sticky Technique, but before we talk about how it works, first a quick primer on how sticky positioning works. The typical use case for sticky positioning is ensuring that section headers in a scrollable list stay in view as you scroll through it. You set position: sticky; top: 0 on your section headers and then when they should normally be scrolled out of view, they stay fixed to the top of the scroll view as the content below scrolls underneath.
Section Title 1 (stuck)
Item 1
Item 2
Item 3
Item 4
Item 5
Section Title 2 (stuck)
Item 6
Item 7
Item 8
Item 9
Item 10
Section Title 3 (stuck)
Item 11
Item 12
Item 13
Item 14
Item 15
Item 16
Item 17
Item 18
Item 19
Item 20
For CodeView, we invert the usual sticky behavior. Instead of pinning the top of the rendered content to the top of the viewport as you scroll down, the bottom edge of the rendered region sticks to the bottom of the viewport when you scroll past it. When you scroll back up, the top edge sticks to the top of the viewport.
This gives us native scrolling while the viewport is inside the rendered range. If JavaScript falls behind, the rendered region sticks to one edge instead of scrolling away and exposing blank space. We can get that behavior with negative top and bottom sticky offsets, both calculated with the same formula: (contentHeight - viewportHeight) * -1.
So to circle back to the goals we set for ourselves: we preserve native scrolling, render updates do not need to be frame-perfect to keep scrolling feeling smooth, and even large jumps cannot scroll past the rendered content into blank space.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββ β ββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β β β
β β Full-height content element β β
β β β β
β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β βββββ βββββ β β β β βββββ Buffer element βββββ β β β β βββββ before virtualized content βββββ β β β β βββββ βββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β β
β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β β β βββ Browser βββ β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ’ β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β βββββββββββββ βββββββββββββ β β β β β β βββββββββββββ Rendered content βββββββββββββ β β β β β β βββββββββββββ βββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β β β β ββββββββββββββββββββββββββββββββββββββββββββββ β β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β ββββββββββββββββββββββββββββββββββββββββββββββ β | β β ββββββββββββββββββββββββββββββββββββββββββββββ β | β β β | β β β | β β β | β β β | β β β | β β β | β β β | β ββββββββββββββββββββββββββββββββββββββββββββββββββ | ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
While we were shooting for
impossible to blank, Safari still found a way to break our hearts. Under sufficiently aggressive scrolling, it can get backed up at the compositing layer and expose blank space. It usually takes some work to pull off, but it is still technically possible.
With virtualization in place, the next problem was calculating the layout and size of the scrollable region. A virtualizer works best when its estimates are close to reality. Bad estimates mean more corrective work after render: measuring DOM, updating item positions, adjusting scroll height, and sometimes fixing the scroll offset to keep the current content in place. The more often that happens, the more likely the page is to stutter or make the scrollbar jump around.
Fortunately, the first pass is pretty cheap. Files are basically lineHeight * totalLines. Diffs are only a little more complex because we already have the parsed line counts and hunk metadata. From there, we just add the hunk separators into the estimate. Simplified, it looks like this: (lineHeight * diff.splitLineCount) + (diff.hunks.length * hunkSeparatorHeight).
With our rough estimates in place, CodeView can determine which files should be rendered. From there, each rendered file or diff gets the viewport size and position, and uses that to decide which lines should be rendered internally.
This architecture came from the previous Virtualizer, but CodeView pushed us to optimize some of the expensive paths. The old implementation could end up iterating through a file or diff from the beginning to find where the rendered range should start and end. For most files and diffs, that cost was effectively invisible. But once we started testing much larger change sets, it became a problem. A hunk with hundreds of thousands of lines could become pathologically expensive because the lookup still had to start from zero.
To work around this, we added a cached position to line checkpoint system. That lets us use binary search to find a closer starting point before doing the remaining range search.
Once a line range is rendered, each file can verify its internal estimate against the actual DOM and store any deltas. That lets the first-pass layout stay cheap while still correcting the cases where the estimate was wrong.
Scroll anchoring is less about raw performance and more about keeping the view stable while layout changes. If content above your scroll position changes height, the browser normally tries to preserve what you were looking at instead of letting it jump around.
Browsers have built-in scroll anchoring for this, but virtualized views make that mostly impossible. The mounted DOM is constantly changing, and the browser cannot make a safe decision about which element to anchor to. For CodeView, we disable the browserβs built-in anchoring with overflow-anchor: none and handle it ourselves.
The core idea is that CodeView can choose an anchor from its own layout model before committing DOM changes. It does not need to ask the DOM what the user is looking at; it already knows which file or line should be visible at each scroll position.
A typical render update looks roughly like this:
Taken together, rough estimates, line-range rendering optimizations, incrementally measured deltas, and scroll anchoring let CodeView stay fast even with very large diffs, without requiring perfect layout information up front.
At this point CodeView was in a pretty good place. It could render diffs as large as Bunβs Zig to Rust rewrite or an even larger Node.js V8 update without falling over.
So, in typical Pierre fashion, we found a larger diff and kept going (weβre probably hiring btw). The next set of work came from trying to render the diff between Linux v6 and v7 more efficiently.
Pathological cases like the Linux diff above can mean more than 700 MB of patch content to parse and render. One of the first things our diff renderers need is a data structure built from that patch file: line content and hunk metadata needed to render them efficiently and correctly.
The subtle problem is that parsed strings can keep more memory alive than you expect. Depending on how the JavaScript engine represents substrings, a small string can still reference the much larger string it came from. That means you can parse a huge patch, keep only the lines you need, and still accidentally retain the original giant input string.
In that case, copying strings can actually save memory. By forcing the parsed line content to detach from the original patch input, Diffs can keep the data they need without keeping the entire source string alive.
This was a good fit for an agent loop because the problem was narrow and easy to test. We had a clear hypothesis, a parser function with well-tested inputs and outputs, and an easy way to check whether each change improved memory usage and parse time.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β β β Memory usage compared (Linux v6...v7 diff) β β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ’ β β β ββββββββββββββββββββββββββββββββββββββββββββββββββ β β ββββββββββββββββββββββββββββββββββββββββββββββββββ β β β β Original (2.4 GB) β β β β ββββββββββββββββββββββββββββββββββββββββββββββββββ β β β β ββββββββββββββββββββββββββββββββββββββββββββββββββ β β ββββββββββββββββββββββββββββββββββββββββββββββββββ β β β β Optimized (1.15 GB) β β β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
After about an hour of iteration, we had some clear wins. Memory usage on the Linux diff dropped from 2.4 GB to around 1.15 GB, and parse time dropped by about 80%.
Virtualization keeps the mounted DOM small, but it can also create a lot of DOM element churn. During aggressive scrolling, CodeView may remove one set of file or diff elements and mount another. Those allocations do not disappear for free: JavaScript objects, derived data, event handlers, and DOM nodes all eventually have to be cleaned up, and enough garbage collection can show up as main-thread pauses.
There was also repeated setup work every time a new file or diff was rendered. Each one lives inside a Shadow DOM wrapper that includes things like stylesheets, theme styles, and an SVG icon atlas. Recreating all of that every time an item scrolled in or out of view was unnecessary work.
So we added a pool for those containers. Instead of throwing the whole wrapper away, CodeView can clean out the item-specific DOM and reuse the shell for the next file or diff. That reduces allocation churn, avoids rebuilding the same wrapper structure over and over, and keeps garbage collection further away from the scrolling path.
A nice side effect of building the pool was that it forced us to be more deliberate about cleanup. Reusing containers safely meant being explicit about clearing references and removing item-specific state, which helped patch a few leaks along the way.
options StateWhile we were testing against the Linux diff, one thing we noticed was that configuration changes were extremely expensive.
File and FileDiff were originally designed to each have their own options object. That worked well for rendering a single file or diff, but it scaled poorly once CodeView was managing tens of thousands of them. Options include things like split or unified layout, line numbers, line wrapping, and other display settings. When one of those values changed, we would end up walking every file or diff instance to give it a newly spread options object.
With enough instances, that became expensive quickly.
The fix was to keep the options shape, but change where the state actually lived. Instead of giving every file or diff its own fresh config object, CodeView owns the current options as the source of truth. Each rendered item gets a stable options object with specialized getters that read from that shared state.
From the itemβs perspective, it still reads options like normal. Underneath, those values are always coming from the latest CodeView configuration.
That means cosmetic changes no longer require rewriting configuration across every item in the review. CodeView can update the shared state, re-render the mounted range, and let the visible files and diffs read the latest values through the same options object. Layout-affecting changes may still need to invalidate estimates, but we already spent time making those much more efficient earlier in the post. Anecdotally, we also noticed a 20-30 MB memory reduction on the Linux diff after implementing this.
This is a feature weβve had in Diffs for a while, but it is still an important piece of making large reviews feel smooth. Syntax highlighting is one of the most expensive processing tasks we do. We use Shiki because it is fast enough for most cases, has a ton of language support, and can run in a variety of contexts: the browser, web workers, and server-side rendering.
But βfast enoughβ changes when you multiply it across a large review. A 2,000-line TypeScript file might only take a few milliseconds to highlight, but that is still expensive inside a strict frame budget, especially when many files are being rendered or updated at once and the main thread is already busy with rendering and virtualization work.
Whatβs important is that highlighting is deferred. Files and diffs can render first as plain text, then request highlighted output from the worker pool. Each worker owns its own Shiki highlighter, keeping the expensive work off the main thread while still allowing multiple highlight jobs to make progress.
Additionally, we keep an LRU cache of highlighted results and provide APIs to prime the highlight cache if we know a file will be rendered soon. That helps avoid repeating work when code comes back into view, while still putting a hard limit on how much highlighted output can be retained.
The goal is for highlighting to improve the review surface, not block it. Code is readable immediately, and highlighting can progressively enhance the experience.
If youβve made it this far: damn, thank you. β₯
This has been a large project, with a lot of complicated work behind it. Iβm proud of what weβve managed to pull off inside the confines of a browser. Should all of this be happening in a browser? Probably not. But, you know, challenge accepted.
So far, weβve mostly talked about the wins: the virtualization techniques, layout estimation, memory improvements, DOM pooling, shared options, and deferred highlighting. Those are real improvements, but there are still plenty of rough edges.
One of the bigger ones is CSS. Some of the most expensive parts of the virtualization system now come from layout and paint. In normal use, thatβs usually fine. During aggressive scrolling, though, those costs can become the majority of the work. Weβve thrown some agentic research loops at this, but so far we havenβt made much progress.
Another unresolved issue is serialization in the highlighting pipeline. If you syntax-highlight a file with tens of thousands of lines, sending that data back and forth through the worker pool gets noticeably expensive. At times, itβs enough to dominate the main thread. This is probably an area where a more server-based streaming approach would make sense.
Finally, while we do line-based virtualization, we donβt virtualize horizontal scrolling or extremely long lines, like you might see in minified JS or CSS. That means mounting one of those lines can still create a sizable DOM hit. We do have safeguards to stop the highlighter from crashing on very long lines, but thatβs a separate problem.
Future plans for Diffs include things like lightweight editing, semantic diffs, and maybe even moving some of this work onto the server where it makes sense. In the meantime:
You should be able to just render any diff.
So hit play on Sandstorm and scroll some diffs.
Before I wrap this up, I wanted to end on a quick note about Safari. A lot of CodeView is built on browser primitives that worked consistently across Chrome and Firefox. In WebKit, that was not always the experience. Between poor performance and limited observability, many wins felt like one step forward and then a half step back.
This is not meant as a dunk on Safari. WebKit is an important target for us, especially because of macOS and the popularity of Tauri. I want nothing more than to build first-class experiences on WebKit.
Hereβs a non-exhaustive list of issues weβve run into while developing CodeView and Diffs:
Inverse Sticky Technique can still blank under aggressive scrolling).other represent in frame timelines, and why is it often blowing up our frame buffers?requestAnimationFrame still being capped at 60Hz, even on higher refresh-rate displays.Work on Safari or on WebKit? Would love to talkβββemail amadeuspierre.co.