CSS content-visibility: The Web Performance Boost You Might Be Missing

The content-visibility CSS property delays rendering an element, including layout and painting, until it is needed

Trevor I. Lasn Trevor I. Lasn
· 2 min read
Building 0xinsider.com — see who's winning across prediction markets (Polymarket, Kalshi, and more) — and what they're trading right now.

Web performance optimization can be a real headache. Shaving off milliseconds here and there, minifying everything in sight, and praying to the performance gods.

Picture this: you’re scrolling through a massive webpage with hundreds of images, complex layouts, and enough content to fill a book. Without content-visibility, browsers dutifully render every single pixel, whether you can see it or not. It’s like a restaurant cooking every dish on the menu just in case someone orders it.

The content-visibility property tells browsers they can skip rendering elements until they’re about to enter the viewport. This might sound simple, but it’s a game-changer for long scrolling pages.

The contain-intrinsic-size property is content-visibility’s partner in crime. It provides a size estimate so the browser can reserve space before rendering, preventing layout shifts.

content-visibility works best on pages with lots of complex, off-screen content. News feeds, product listings, and documentation sites are perfect candidates. I’ve seen initial render times improve by 30-50% on content-heavy pages.

One important detail: content-visibility doesn’t just defer paint operations - it skips layout calculations entirely. This means the browser doesn’t waste time figuring out how to position elements nobody can see yet.

content-visibility isn’t free magic though. Each element with content-visibility: auto becomes a separate containing block. This can affect positioning and scroll anchoring. Here’s what to watch for:

After experimenting with content-visibility across different scenarios, I’ve found it works best when:

  1. Sections are clearly defined and independent
  2. Content below the fold is complex
  3. Users typically don’t need immediate access to hidden content

Feeds are a great example - users rarely jump straight to the bottom, and each post is self-contained.


Trevor I. Lasn

Building 0xinsider.com — see who's winning across prediction markets (Polymarket, Kalshi, and more) — and what they're trading right now. Product engineer based in Tartu, Estonia, building and shipping for over a decade.


Found this article helpful? You might enjoy my free newsletter. I share dev tips and insights to help you grow your coding skills and advance your tech career.


Related Articles

Check out these related articles that might be useful for you. They cover similar topics and provide additional insights.

Webdev
8 min read

Why localStorage Is Unsafe for Tokens and Secrets

localStorage is vulnerable to XSS and has no expiry or encryption. Learn why httpOnly cookies and sessionStorage are safer for auth tokens.

Oct 28, 2024
Read article
Webdev
3 min read

Preloading Responsive Images

How to properly preload responsive images to improve initial page load

Nov 28, 2024
Read article
Webdev
5 min read

Programming Trends to Watch in 2020 and Beyond

Here are my bets on the programming trends

Jul 19, 2019
Read article
Webdev
13 min read

10 Essential Terminal Commands Every Developer Should Know

List of useful Unix terminal commands to boost your productivity. Here are some of my favorites.

Aug 21, 2024
Read article
Webdev
6 min read

How I Use Vercel BotID to Stop Bots on Auth Endpoints

BotID verifies browser challenges before proxying to the backend. Here's how I set it up in Next.js 16.

Feb 16, 2026
Read article
Webdev
4 min read

Open Dyslexic Font: Improve Your Web Accessibility

How to implement the Open-Dyslexic font to enhance readability for users with dyslexia

Oct 12, 2024
Read article
Webdev
6 min read

Inside the CSS Engine: CSSOM Explained

A deep dive into how browsers parse and manipulate CSS, its impact on web performance, and why it matters

Oct 25, 2024
Read article
Webdev
4 min read

Self-Taught Developer's Guide to Thriving in Tech

How to turn your non-traditional background into your biggest asset

Sep 28, 2024
Read article
Webdev
5 min read

Mermaid.js — Create Charts and Diagrams With Markdown-like Syntax

Mermaid.js is a simple markdown-like script language for generating charts from text via JavaScript

Oct 30, 2019
Read article

This article was originally published on https://www.trevorlasn.com/blog/css-content-visibility. It was written by a human and polished using grammar tools for clarity.