Offloading virtualization to the browser via CSS Containment #959
Replies: 3 comments 2 replies
-
I was very optimistic about this spec when it came out. As much as I love my work, in the ideal world, the browser should support this and Virtuoso should be obsolete and I can retire :). CSS containment must help with the browser rendering performance, but you will still have to fetch all data from the server and render it with React - which is a lot of work, most of the time. One can probably handle that with intersection observers and lazy conditional rendering/data fetching, but then you lose the native find feature. This being said, perhaps there's something in there. Maybe not a whole lot of it, given that intrinsic size still has to be managed. |
Beta Was this translation helpful? Give feedback.
-
While modern browsers can easily display scrollable panels with thousands of elements (engines are smart enough to skip processing of elements that lay outside of visible area) we should still try to avoid large DOM (waste of memory, slower selectors, really bad impact on devtools performance etc.). The more important thing is that browser can do its tricks only after React does its rendering (runs the components) and this could be prohibitively slow, especially in grid scenarios (100x100 is 10K components). Maybe one day it will be built into React somehow (Intersection Observer API?) so component rendering will be automatically skipped if it would not be visible anyways (but how about sizing?)... |
Beta Was this translation helpful? Give feedback.
-
The point is that Virtuoso is preventing two things: rendering (the React part) and painting (the DOM/Browser part)... Virtuoso is already able to know where to place content (using The pain point is browser support 😓 |
Beta Was this translation helpful? Give feedback.
-
Hey all! I'm trying to understand how much benefit there still is to actually render virtualized lists, versus using CSS content-visibility on the lists instead? To me it seems that both approaches want to help the browser work faster by not rendering offscreen content.
But as react-virtuoso (and other virtualization libraries AFAIK) still do all of the work in JS, I wonder what the benefit of that is? Has it been benchmarked in some way? Usually native solutions, especially moving this kind of functionality from JS to CSS results in the best performance.
I guess there may still be some wrapper library around CSS Containment necessary, to measure the items and set
contain-intrinsic-size
, etc, but if we could remove a bunch of JS by using CSS features instead...Edit: Seems that the browser support ain't too good yet.
Beta Was this translation helpful? Give feedback.
All reactions