Use content-visibility to lazy-render out of viewport elements

Created on 4 February 2024, 4 months ago
Updated 3 May 2024, 20 days ago

Problem/Motivation

Explanatory article here: https://web.dev/articles/content-visibility

tl;dr, if you add content-visibility: auto; to container elements, entities, blocks, and layout builder regions are the obvious ones, then chrome >= 85 won't render it until it comes into the viewport, dramatically speeding up total page rendering and time to interactivity.

content-visibility: auto;
contain-intrinsic-size: auto 300px;

A classic example where this would help us is comment rendering, especially the infamous https://drupal.org/node/2429699 which nearly crashes my browser every time I load it.

However it would also help less dramatically but still a lot on teaser listings, large pages built with layouts, and we could probably use it for rows in tables on views admin pages and large forms like the permissions form maybe.

Steps to reproduce

Proposed resolution

There doesn't seem to be any downside to using this, so I think we should apply it to all the places that make sense at least in Claro, Olivero, and Umami. However it's tempting to add the CSS in system module somewhere so that everywhere can just add a class. It's also a bit tempting to add that class centrally too, but we could discuss whether to do that in a follow-up and just apply it to individual themes for now.

Merge request link

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
CSSΒ  β†’

Last updated about 17 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024