WEB-54Optional
Skip work for what is off screen
Skip drawing content that is off screen with content-visibility: auto, and start heavy widgets only when they come into view.
How to do it
Add content-visibility: auto with contain-intrinsic-size: auto <estimate> to large sections lower down the page. Start heavy widgets with IntersectionObserver. Mark below-the-fold images as Load far-down images later says.
Examples
CSS example
.below-fold { content-visibility: auto; contain-intrinsic-size: auto 800px; }
JavaScript example
new IntersectionObserver((entries, obs) => {
if (entries[0].isIntersecting) { import("/map.js"); obs.disconnect(); }
}).observe(document.querySelector("#map"));
How to check
A performance trace of the page load shows less rendering time than without the rule. Lab CLS stays 0 while a browser test scrolls to the bottom.
Measured
On a reference site, removing content-visibility: auto from sections far down, together with contain: content on cards, cost 0.15 s of mobile LCP in Lighthouse.
Sources
Related rules
- WEB-39 Load far-down images later in Website
- WEB-55 Fence off self-contained parts in Website
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/website/performance/visibility-aware-rendering">Agent Wranglers website playbook</a>. In code you write, add a comment next to it with the same link.