TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

How I made Google’s data grid scroll faster with a line of CSS

454 pointsby mankzover 3 years ago

21 comments

lxeover 3 years ago
I&#x27;ve been doing web development for 20 years now. I don&#x27;t know if it&#x27;s strictly endemic to web or frontend, but I feel like we&#x27;re solving the same problems over and over again, using the same low levels of abstraction.<p>There&#x27;s no reason for lists to scroll slowly after so many years of scrolling lists. There should just be one way to do a scrolling list, implemented natively and left alone. Yet, in web development, there&#x27;s always a new and different way to do a thing, with either new, or pretty much the same ways for things to be broken.<p>Grumble grumble
评论 #29020291 未加载
评论 #29020177 未加载
评论 #29019484 未加载
评论 #29019322 未加载
评论 #29019197 未加载
评论 #29021045 未加载
评论 #29019749 未加载
评论 #29019983 未加载
评论 #29021857 未加载
评论 #29020148 未加载
评论 #29024058 未加载
评论 #29019562 未加载
评论 #29020715 未加载
tdrdtover 3 years ago
<a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;contain" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;contain</a><p><i>The contain CSS property allows an author to indicate that an element and its contents are, as much as possible, independent of the rest of the document tree. This allows the browser to recalculate layout, style, paint, size, or any combination of them for a limited area of the DOM and not the entire page, leading to obvious performance benefits.</i><p>I wonder how much of this is browser specific because isn&#x27;t this is all about implementation?
评论 #29019624 未加载
CodeIsTheEndover 3 years ago
TIL: Chrome DevTools Layers tab, accessible by going to to the three-dot menu &gt; More Tools &gt; Layers, which allows you to see things rendered outside of the browser viewing area (among many other things I&#x27;m sure).<p>If you have something that &quot;unmounts&quot; things as they scroll off the screen (&quot;virtualized rendering&quot; as the article calls it, a common feature for data grids), this is great tool for verifying that behavior.
评论 #29023925 未加载
评论 #29023116 未加载
eskaover 3 years ago
I’m not a frontend dev so I just stick to vanilla html and js.<p>I created a simple table with 40k rows, slapped an input box above it, and had some vanilla js set CSS visibility on all rows depending on whether they matched. This would update live as I was typing (10ms trigger delay). No optimizations.<p>So what are frontend devs doing that they break all of this so badly? Are they just trying to be too smart, I wonder?
评论 #29019660 未加载
评论 #29019513 未加载
评论 #29019626 未加载
评论 #29019510 未加载
评论 #29019501 未加载
评论 #29019538 未加载
评论 #29023943 未加载
评论 #29020867 未加载
评论 #29019468 未加载
评论 #29023400 未加载
评论 #29020337 未加载
评论 #29021275 未加载
anonyglerover 3 years ago
That jscontroller= stuff in the DOM is Google’s internal framework called Wiz. Easily one of the worst things I’ve used in my career. It’s like a hyper engineered Backbone.js. Working with it is so tedious that passionate web developers who might fix these perf issues burn out and leave. What’s left are promo-seeking impact farmers who don’t really care about these sorts of things.
评论 #29022556 未加载
jaywalkover 3 years ago
I have never heard of the &quot;contain&quot; property before this article. It seems like it can be very useful.
评论 #29019346 未加载
评论 #29019547 未加载
hitekkerover 3 years ago
Wow, $2040 for a table component: <a href="https:&#x2F;&#x2F;www.bryntum.com&#x2F;store&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.bryntum.com&#x2F;store&#x2F;</a>.<p>I&#x27;d pay that in a heartbeat if it had the API and UI that fits in with the rest of my software. Better an upfront price in dollars for a component that I know will be well-supported by a company than a &quot;free&quot; component that will likely be abandoned or mismanaged by one bored developer
评论 #29019943 未加载
评论 #29021305 未加载
codedokodeover 3 years ago
The article still doesn&#x27;t answer how scrolling a page can cause layout change. Layout change occurs when elements are added or removed from DOM or when they change their size. I assume there is some Javascript that updates styles on scroll event.
评论 #29023147 未加载
评论 #29019701 未加载
onoxover 3 years ago
<a href="https:&#x2F;&#x2F;web.dev&#x2F;content-visibility&#x2F;" rel="nofollow">https:&#x2F;&#x2F;web.dev&#x2F;content-visibility&#x2F;</a> has a nice blog post about &quot;content-visibility&quot; and &quot;contain&quot;.
joshspankitover 3 years ago
I expected a soft-sell somewhere in this article, and the depth of knowledge had me say “respect. I’ll check out this sell”, but I did <i>not</i> expect $2040&#x2F;yr for the JS table library!
评论 #29022929 未加载
fleddrover 3 years ago
Note the related CSS property &quot;content-visibility&quot;:<p><a href="https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;content-visibility" rel="nofollow">https:&#x2F;&#x2F;developer.mozilla.org&#x2F;en-US&#x2F;docs&#x2F;Web&#x2F;CSS&#x2F;content-vis...</a><p>Whereas &quot;contain&quot; prevents recalculations, &quot;content-visibility&quot; doesn&#x27;t render applicable elements at all until needed.
评论 #29021235 未加载
TheSisb2over 3 years ago
Shameless plug: we had a really hard time finding an accessible data grid that matches the specs, so we built one recently (in React) for our design system. It’s very minimal but completely composable. For example we don’t have virtualized rows or frozen columns but that’s something that can be added on later; we focused on a foundationally accessible data grid to start: <a href="https:&#x2F;&#x2F;paste.twilio.design&#x2F;components&#x2F;data-grid" rel="nofollow">https:&#x2F;&#x2F;paste.twilio.design&#x2F;components&#x2F;data-grid</a><p>I hope that other data grid libraries can mimic some of this to improve web accessibility. These components can be really tedious to interact with today
thanhhaimaiover 3 years ago
Opinions are my own.<p>I don&#x27;t think this is recommended to use internally at Google because it&#x27;s not supported on Safari.
评论 #29019359 未加载
评论 #29019276 未加载
trhwayover 3 years ago
&gt;The full page contains 38,000+ (!) elements, which is not how you build a fast web app! The obvious thing to do here would be to change to using a data grid with virtualized rendering<p>more than 20 years ago we worked on a browser and had tests with tens of thousands table rows. That was fun. The 40K elements today should be absolutely no issue ... until of course :<p>&gt; the entire page is laid out when you scroll the grid.<p>and that is the root issue here. For the smooth scroll it should be scrolling over already laid out page (or at least laid out well ahead part of the page).
hayksaakianover 3 years ago
I hope the engineer who works on search console sees this and implements it.<p>Google Search Console is just unusable for browsing large data sets due to this issue.
atum47over 3 years ago
Just to be clear, Google console is a nightmare in terms of ui&#x2F;ux. I had to use it a lot when publishing my games or creating ads for them.
DigitalSeaover 3 years ago
What makes this even more ironic, is that for a period of time, Chrome was one of the only browsers to support the contain property. I&#x27;ve been using this property for years to speed up my applications, it does have quirks (especially using strict), but reading up on the different modes it can offer huge performance gains for large apps.
FractalHQover 3 years ago
Svelte has solved performance, and made writing butter smooth, lightning fast web apps 10x easier with 10x less code. Blows my mind that more companies haven’t adopted it considering devs fall in love with the unmatched DX, and users get highly optimized apps shipped to them at a faster rate thanks to the boost in dev speed.
robbiejsover 3 years ago
If anyone is looking for the FASTEST data grid in the world, here is a One Million Cells demo: <a href="https:&#x2F;&#x2F;www.datagridxl.com&#x2F;demos&#x2F;one-million-cells" rel="nofollow">https:&#x2F;&#x2F;www.datagridxl.com&#x2F;demos&#x2F;one-million-cells</a>.<p>(Disclaimer: I am the maker of the product)
评论 #29043901 未加载
eccosesover 3 years ago
Well done - excellent skills.
b20000over 3 years ago
hey, at least those googlers all passed leetcode.
评论 #29032261 未加载