brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: content-visibility: auto in css skips rendering of cards that are off screen

Css
~/tips/tip-css-content-visibility-auto-cards

.post-card { content-visibility: auto; contain-intrinsic-size: auto 400px; }

Skips layout and painting of off-screen elements to make long pages render faster.

Long pages with hundreds of cards spend time on rendering things nobody can see yet.

.post-card { content-visibility: auto; contain-intrinsic-size: auto 400px; }

With content-visibility: auto the browser skips layout and painting for an element until it comes near the viewport. contain-intrinsic-size gives the skipped element a placeholder height so the scrollbar does not jump, and the auto keyword makes the browser remember the real size once it has been rendered. Find-in-page still reaches the hidden text. Measure before and after, since a short page gains nothing and a wrong placeholder height makes the scroll position shift.

Further reading: MDN: content-visibility

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link