Native browser virtual scroller

AI-generated summary

The discussion revolves around the development of native browser virtual scrolling and related APIs, with a focus on improving performance and accessibility for large-scale web content. dfabulich highlights emerging standards like the virtual-scroller API, find-in-page-api, searchable-invisible-dom, and display-locking, which aim to enhance find-in-page functionality, a11y navigation, and rendering efficiency. However, the display-locking API faced opposition from Mozilla and Apple, leading to a shift in direction. dfabulich notes that the effort evolved into the content-visibility property, which has been implemented in Chrome 85 and is supported in Edge and Opera. The property allows developers to defer rendering of offscreen content, significantly improving performance. codinghorror expresses concern over the bandwidth required to participate in such standards work, while dfabulich shares a video and article demonstrating the effectiveness of content-visibility.

Browsers are beginning to form a standard around browser-native virtual scrolling.

[GitHub - WICG/virtual-scroller · GitHub]

A built-in virtual scroller for the web platform

They’re also exploring some really interesting low-level browser APIs that would allow find-in-page and a11y navigation for large volumes of invisible content.

[GitHub - rakina/find-in-page-api · GitHub]

There have been a lot of interest in improving the find-in-page experience from web developers, including:

  • Giving the user a completely custom UI, suppressing the browser’s find UI, consistently
  • Allowing data not in the DOM tree to be findable, even if there might be an infinite amount of data
  • Reflecting real-time data loading/modification on find results
  • Treating multiple webpages as one searchable instance, e.g. books, multi-page articles, or the multipage HTML spec

[GitHub - rakina/searchable-invisible-dom · GitHub]

The proposal is to create some new way of exposing DOM to the browser, that is still searchable, but is invisible. That is, find in page must be able to search within this DOM and fragment navigation should be able to find a named invisible DOM, etc., but we shouldn’t need to do all the work of layout/paint/etc.

[GitHub - WICG/display-locking: A repository for the Display Locking spec · GitHub]

This document proposes to augment user-agent APIs to help address the problem of slow rendering phase updates, and having some control on when to pay rendering costs. Specifically, we propose a concept of display locking an element.

If an element is display locked, it means that any DOM, style or layout updates to its subtree are not rendered immediately. Instead, when allowed, the user agent will process rendering updates co-operatively, yielding periodically to allow script or user interactions to happen. The web author can also commit the lock, which triggers a synchronous update and render when necessary, causing the element to get updated and rendered in the next frame.

The web author can also opt-in to allow display-locked elements to be committed by the user agent in cases like focus navigation, find-in-page match navigation, etc. so that they are properly rendered when needed in those cases.

Stuff like this seems highly relevant to the implementation of Discourse.

FYI, it’s looking like Google’s Plan A approach to this is falling apart. Mozilla and Apple have come out against the Display Locking API. content-visibility API · Issue #135 · mozilla/standards-positions · GitHub

It might be wise to start participating in this conversation sooner than later. My understanding is that Chrome has a working prototype implementation behind a flag. It might be worth building out a prototype to see what y’all like and don’t like about it.

There’s no way we’d have the bandwidth to get involved in this.

Did this go anyhere @dfabulich ?

Yes! The browser standard evolved to become the content-visibility property. It shipped in Chrome 85, and therefore also available in Edge and Opera. https://caniuse.com/?search=content-visibility

Watch this video… it’s freakin’ amazing.

Here’s an in-depth article about it.