by gloria_mundi · 6mo ago · 0 comments
Also ... shouldn't browsers just be able to render the diff without any of the trickery? Is the browser's job actually that hard for long pages, or are they just not optimising for this? Or is there some other reason for the virtualisation (e.g. memory usage)?
The only time you will is if you’re scrolling at a rate where the jumps are quite large — large and fast enough typically where you’re not going to have a frame of reference for what you should see vs what you are seeing to notice you are behind.
Ultimately scrolling is managed on a separate thread from JS, which means if you do like an opt+click on the scroll bar, you’re going to make a jump that JavaScript can never keep up with, even if you’re under your frame times.
And with regards to safari, if your requestAnimationFrame is capped at 60hz but your scrolling is GPU composited at 120hz, this is the only way to keep scrolling at 120hz with 60hz dom updates and never see any blanking.
And yes, browsers should be just able to render the diffs, if the styling is somewhat minimal and there is no JS: I have a 6.3-MiB large HTML file with complete transcript of a certain TV series, formatted like
<dd><b>Character #1</b>: Well, that was interesting all right.</dd>
<dd><b>Character #2</b>: [sigh]</dd></dl>
<dl><dd><b>Character #1</b>: Lemme help you.</dd>
<dd><b>Character #3</b>: Yeehaw!</dd>
<dd>[thump]</dd>
(the </dl><dl> produces a small paragraph break, to indicate scene transitions), and it scrolls and searches just fine.