What Is CSS content-visibility and Does It Make Websites Faster?
CSS content-visibility allows the browser to skip rendering work for content that does not currently need to be displayed. With content-visibility: auto, the browser can skip layout and painting for off-screen sections while keeping those sections available to browser features such as find-in-page, keyboard navigation, selection, and the accessibility tree. This makes the property particularly useful for long pages containing many independent sections, cards, articles, or other expensive content.
The important part is that content-visibility does not magically make every website faster. Its value comes from reducing unnecessary rendering work. The best candidates are pages with substantial off-screen content where the browser would otherwise spend time calculating layout and painting elements the user has not reached yet. Pairing content-visibility: auto with contain-intrinsic-size can also reserve approximate space for skipped content and reduce layout movement when that content becomes visible.
That makes content-visibility one of those CSS features that looks almost too simple.
section {
content-visibility: auto;
}
One line.
But behind that line is an important browser-performance concept:
Don’t spend rendering resources on content the user doesn’t currently need.
For developers building content-heavy websites, documentation portals, dashboards, marketplaces, feeds, and long landing pages, that can be a useful optimization.
1. Hook: Your Browser May Be Rendering Things Nobody Is Looking At
Open a long webpage.
Maybe it contains:
- A hero section
- 20 feature sections
- Testimonials
- Pricing
- FAQs
- Case studies
- Related articles
- Footer content
The user sees only the top portion.
But traditionally, the browser still has to process a large amount of document structure and rendering work.
Think about a page like this:
Viewport
┌─────────────────────────────┐
│ Hero │
│ Visible │
├─────────────────────────────┤
│ Features │
│ Visible │
├─────────────────────────────┤
│ Testimonials │
│ Below viewport │
├─────────────────────────────┤
│ Case Studies │
│ Below viewport │
├─────────────────────────────┤
│ FAQ │
│ Far below viewport │
├─────────────────────────────┤
│ Footer │
│ Far below viewport │
└─────────────────────────────┘
The user hasn’t asked to see the FAQ yet.
They may never scroll that far.
So why should the browser spend unnecessary rendering effort on everything immediately?
That’s the problem content-visibility addresses.
2. Setup: Rendering Is More Than Downloading HTML
Website performance discussions often focus on:
- HTML size
- JavaScript bundle size
- Images
- Fonts
- Network requests
Those matter.
But once the browser has downloaded your page, it still has work to do.
The rendering process involves creating the DOM, processing styles, building the render tree, calculating layout, and painting pixels. MDN describes the critical rendering path as the sequence through which HTML, CSS, and JavaScript are converted into the pixels displayed on screen.
That means a page can have:
Small network payload
+
Heavy rendering work
and still feel slow.
This is particularly relevant to large applications.
Imagine a dashboard with:
500 cards
100 charts
50 interactive widgets
20 tables
Most of them aren’t visible simultaneously.
The browser shouldn’t necessarily treat every off-screen section as equally urgent.
3. The Turning Point: Let the Browser Skip Work
This is where content-visibility: auto becomes interesting.
Consider:
.card-section {
content-visibility: auto;
}
You’re effectively telling the browser:
This section may not need to be rendered until it becomes relevant to the user.
MDN explains that content-visibility: auto enables containment and allows the user agent to skip rendering work for content that isn’t relevant to the user at that moment.
That can include:
- Layout work
- Style-related work under containment
- Painting
The browser decides when the content needs to be rendered.
This is different from manually hiding content with JavaScript.
You’re not deleting the content.
You’re not removing it from the document.
You’re telling the browser it doesn’t need to perform all rendering work immediately.
4. The Basic Example
Suppose you have:
<section class="article-section">
<h2>Introduction</h2>
<p>...</p>
</section>
<section class="article-section">
<h2>Performance</h2>
<p>...</p>
</section>
<section class="article-section">
<h2>Accessibility</h2>
<p>...</p>
</section>
<section class="article-section">
<h2>Advanced Techniques</h2>
<p>...</p>
</section>
You can write:
.article-section {
content-visibility: auto;
}
The browser can skip rendering work for sections that are sufficiently far outside the user’s current view.
As the user approaches them, the browser renders them.
That’s the core idea.
5. Why This Is Different From display: none
This distinction is important.
Consider:
display: none;
The element is removed from the rendered layout.
It isn’t available to users in the same way.
By contrast:
content-visibility: auto;
allows the browser to skip rendering work while preserving the content for browser functionality.
MDN specifically notes that content skipped through content-visibility: auto remains available for features such as find-in-page, tab-order navigation, focus, selection, and the accessibility tree.
That’s a major difference.
You’re not saying:
Hide this.
You’re saying:
Don’t spend rendering resources on this until it matters.
6. The UI/UX Benefit: Performance Without Removing Content
This is where the property becomes especially useful.
Suppose your documentation page contains:
Introduction
Installation
Configuration
Authentication
API Reference
Examples
Troubleshooting
FAQ
Users may scroll through the page naturally.
You don’t want to:
Remove sections
↓
Wait for JavaScript
↓
Insert sections later
That could complicate:
- Accessibility
- Search
- Find-in-page
- Keyboard navigation
- Browser behavior
content-visibility: auto provides a browser-level optimization instead.
The content remains part of the page.
The browser simply avoids unnecessary rendering work until needed.
7. Where content-visibility Is Most Useful
Good candidates include:
Long articles
Technical documentation and editorial pages can contain thousands of words.
Product pages
Long SaaS landing pages may have dozens of sections.
Dashboards
Large dashboards often contain widgets far below the viewport.
Feeds
Social and activity feeds can become expensive as content grows.
Documentation
Large documentation pages can contain many code blocks and examples.
E-commerce
Category pages can contain large product grids.
Knowledge bases
Long collections of articles and support content can benefit from deferred rendering.
The common characteristic is:
There is a lot of content, but only a small portion is immediately relevant to the viewport.
8. When It Is Probably Not Worth Using
Don’t add:
content-visibility: auto;
to every element.
A simple page containing:
Header
Hero
Three paragraphs
Footer
doesn’t need elaborate rendering optimization.
There isn’t enough work to skip.
The optimization becomes more interesting when the DOM or rendering workload is substantial.
For a small page, adding unnecessary containment can make your CSS harder to understand without producing meaningful benefits.
Performance optimization should be evidence-driven.
9. The Most Important Companion: contain-intrinsic-size
Here’s where things become more interesting.
When content is skipped, the browser needs a reasonable idea of how much space that content should occupy.
Otherwise, you can end up with unpleasant layout changes as content becomes rendered.
That’s where:
contain-intrinsic-size
comes in.
For example:
.article-section {
content-visibility: auto;
contain-intrinsic-size: 800px;
}
You’re effectively providing an estimated intrinsic size for the skipped content.
MDN describes contain-intrinsic-size as a way to provide placeholder dimensions for content under containment, helping preserve space and reduce scrollbar movement or layout jank as content becomes rendered.
10. Why Placeholder Size Matters
Imagine this page:
Hero
↓
Section A
↓
Section B
↓
Section C
↓
Section D
If Section C is skipped and the browser has no useful estimate of its size, its space can be represented inaccurately.
Then the section becomes rendered.
Its actual dimensions are discovered.
The page can change.
That can cause a jump.
A better pattern is:
section {
content-visibility: auto;
contain-intrinsic-size: auto 600px;
}
The browser gets a reasonable estimate.
When the actual content is rendered, the approximation can be replaced with reality.
11. Don’t Treat contain-intrinsic-size as a Magic Number
You don’t need to find the perfect number.
The goal is to provide a useful approximation.
If your cards are usually around 400px tall:
contain-intrinsic-size: 400px;
may be reasonable.
If your article sections vary dramatically:
contain-intrinsic-size: 800px;
could be a rough estimate.
The better your approximation, the more stable the page can feel.
For complex layouts, test actual behavior rather than choosing a number randomly.
12. A Practical Pattern for Long Articles
Suppose you’re building a long technical article.
<article>
<section class="article-section">
<h2>What Is It?</h2>
<p>...</p>
</section>
<section class="article-section">
<h2>How It Works</h2>
<p>...</p>
</section>
<section class="article-section">
<h2>Examples</h2>
<p>...</p>
</section>
<section class="article-section">
<h2>Advanced Techniques</h2>
<p>...</p>
</section>
</article>
CSS:
.article-section {
content-visibility: auto;
contain-intrinsic-size: auto 600px;
}
This is a reasonable starting point.
But don’t blindly apply it to every child element.
Containment works best when you choose meaningful independent sections.
13. Think in Sections, Not Individual Paragraphs
This is a common optimization mistake.
You could write:
p {
content-visibility: auto;
}
But that isn’t necessarily a good architecture.
A paragraph is usually too small to justify this kind of optimization.
Instead:
.article-section {
content-visibility: auto;
}
is conceptually cleaner.
Think:
Which chunks of the page are independently expensive?
Those are better candidates.
14. Large Cards Are Better Candidates Than Tiny Elements
Imagine a dashboard:
Card
├── Header
├── Chart
├── Legend
├── Table
└── Controls
The entire card may be expensive.
You could apply:
.dashboard-card {
content-visibility: auto;
contain-intrinsic-size: auto 500px;
}
Now the browser can defer work associated with the card when it is off-screen.
This makes more sense than putting the property on every:
span
p
button
label
15. CSS Containment Is the Bigger Idea
content-visibility is part of a broader CSS containment system.
CSS containment allows developers to communicate that a subtree can be treated as more independent from the rest of the document, allowing browsers to optimize rendering. MDN describes containment as a way to isolate parts of a page so rendering can be optimized more independently.
That matters because browsers have to understand relationships between elements.
If one element changes, the browser may need to determine what else could be affected.
Containment can reduce that uncertainty.
It’s a way of saying:
This part of the page can be treated as its own rendering boundary.
16. Why Rendering Boundaries Matter
Imagine:
Page
│
├── Header
├── Hero
├── Section A
├── Section B
├── Section C
└── Footer
Without useful containment, changes inside one area may require broader calculations.
With containment:
Page
│
├── Header
├── Hero
├── Section A [contained]
├── Section B [contained]
├── Section C [contained]
└── Footer
The browser has more information about independence.
This doesn’t mean the browser ignores the rest of the document.
It means you’ve provided constraints that can enable optimization.
17. content-visibility: auto Does Not Mean Lazy Loading Everything
This distinction is essential.
Image lazy loading:
<img loading="lazy">
is about delaying image resource loading.
content-visibility: auto is about rendering.
They solve different problems.
A page can use both:
<section class="product">
<img
src="product.jpg"
loading="lazy"
alt="Product image"
>
</section>
.product {
content-visibility: auto;
contain-intrinsic-size: auto 500px;
}
Now:
Image loading
+
Rendering work
can be optimized independently.
18. It Doesn’t Replace Good JavaScript Architecture
Suppose your dashboard runs:
setInterval(updateEverything, 100);
content-visibility won’t magically make that architecture efficient.
If JavaScript is continuously:
- Calculating
- Fetching
- Measuring
- Updating
- Animating
then the browser may still spend significant resources even if some visual content isn’t being rendered.
content-visibility addresses rendering work.
It doesn’t automatically stop application logic.
19. The New Opportunity: Use contentvisibilityautostatechange
There’s an interesting browser event associated with content-visibility: auto:
contentvisibilityautostatechange
MDN documents this event as firing when rendering work for an element starts or stops being skipped. It can allow application code to start or stop work, such as drawing on a canvas, when that rendering is actually needed.
That creates an interesting architecture.
Imagine a dashboard widget containing a chart.
Instead of continuously rendering the chart:
Chart always active
you can potentially coordinate work with whether the browser is currently skipping that content.
Conceptually:
Widget off-screen
↓
Rendering skipped
↓
Expensive drawing can pause
Widget approaches viewport
↓
Rendering resumes
↓
Chart work becomes relevant
This can be especially useful for expensive visualizations.
20. Example: Expensive Canvas Widgets
Imagine:
<section class="chart-widget">
<canvas id="sales-chart"></canvas>
</section>
CSS:
.chart-widget {
content-visibility: auto;
contain-intrinsic-size: auto 400px;
}
JavaScript could listen for the relevant event and coordinate expensive drawing.
The important architectural idea is:
Don’t continuously perform expensive work for something the user isn’t currently seeing.
CSS and JavaScript can cooperate instead of competing.
21. This Is Especially Relevant to Dashboards
Modern SaaS dashboards can become enormous.
A single page may contain:
Revenue chart
Traffic chart
User chart
Conversion chart
Activity table
Customer table
Notifications
Tasks
Calendar
Recommendations
If every widget is fully active immediately, the browser has a lot to process.
A better architecture is:
Above-the-fold widgets
↓
Immediate
Off-screen widgets
↓
Deferred rendering
Expensive visualization
↓
Activate when relevant
This is a more scalable mental model.
22. The Myth: content-visibility Fixes Core Web Vitals Automatically
It doesn’t.
Web performance is multidimensional.
web.dev identifies Interaction to Next Paint, or INP, as a Core Web Vital and provides dedicated guidance for optimizing interaction responsiveness.
A website can have:
Good rendering optimization
+
Terrible JavaScript
or:
Excellent server response
+
Huge images
or:
Small HTML
+
Long main-thread tasks
There is no single CSS property that fixes all of that.
Measure before and after.
23. The Myth: It Makes the DOM Smaller
It doesn’t.
Your HTML remains.
The content isn’t deleted.
The browser is skipping some rendering work.
This is an important distinction:
DOM size
≠
Rendered work
You can have a large DOM and reduce some rendering costs.
But a huge DOM can still create other problems.
If your application contains 50,000 unnecessary elements, content-visibility isn’t an excuse to keep them.
Fix the architecture too.
24. The Myth: content-visibility: hidden Is the Same as auto
It isn’t.
Consider:
content-visibility: hidden;
MDN explains that hidden skips the contents and makes them unavailable to user-agent features such as find-in-page and tab-order navigation, more like display: none.
By contrast:
content-visibility: auto;
allows the content to remain available while letting the browser skip rendering when appropriate.
So don’t casually replace:
display: none
with:
content-visibility: hidden
and assume they’re interchangeable in every interaction model.
25. When hidden Is Actually Useful
content-visibility: hidden can be useful when you intentionally control visibility.
For example:
.panel.is-hidden {
content-visibility: hidden;
}
It can preserve rendering state differently from removing and re-adding content through display, depending on the implementation.
But if your goal is:
Keep content available but defer rendering when off-screen.
use:
content-visibility: auto;
That’s the more relevant value.
26. Accessibility: The Important Difference
This feature deserves careful accessibility consideration.
With:
content-visibility: auto;
off-screen content remains in the accessibility tree, according to MDN. It also remains available for keyboard navigation, selection, and find-in-page.
That makes auto particularly interesting for long documents.
However, don’t conclude:
Therefore accessibility is automatically solved.
Your actual interface still needs:
- Correct headings
- Labels
- Focus management
- Semantic HTML
- Logical navigation
- Good contrast
- Proper interactive controls
Rendering optimization doesn’t fix semantic problems.
27. Don’t Put It on Interactive Components Without Testing
Suppose you have:
<section class="panel">
<button>Open settings</button>
</section>
If the panel is off-screen and uses content-visibility: auto, the browser still needs to preserve the relevant interaction semantics.
MDN indicates that skipped auto content remains available for tab navigation and focus.
Still, production components should be tested.
Especially:
- Keyboard navigation
- Screen readers
- Programmatic focus
- Find-in-page
- Anchor links
Performance optimizations should never be accepted without testing the actual user flow.
28. Anchor Links Are a Useful Test
Suppose your article has:
<a href="#advanced">Jump to advanced section</a>
and:
<section id="advanced">
<h2>Advanced Techniques</h2>
</section>
The section may initially be outside the viewport.
Click the link.
Does the browser correctly navigate to it?
This is one of the practical tests worth running when applying rendering containment to long content.
Don’t assume.
Test.
29. Find-in-Page Is Another Useful Test
Press:
Ctrl + F
Search for a word inside an off-screen section.
For content-visibility: auto, the content should remain available to find-in-page according to MDN.
This is a nice example of why auto is fundamentally different from simply hiding content.
The browser can optimize rendering without pretending the content doesn’t exist.
30. The UX Problem: Layout Shifts
Imagine a user is scrolling.
They see:
Section A
Section B
Section C
Section D is skipped.
The user scrolls toward it.
The browser renders D.
If the estimated size was significantly wrong, content may move.
That’s why intrinsic size estimation matters.
MDN specifically describes contain-intrinsic-size as a mechanism for providing placeholder size and reducing layout movement as contained content becomes rendered.
Performance isn’t only:
Make the browser do less work.
It’s also:
Make the resulting experience stable.
31. Use contain-intrinsic-size When Content Has Predictable Dimensions
Good example:
.product-card {
content-visibility: auto;
contain-intrinsic-size: auto 420px;
}
If most product cards are around the same height, the estimate is useful.
Less predictable example:
.article-section {
content-visibility: auto;
contain-intrinsic-size: auto 300px;
}
when some sections contain:
- 100-word text
- 2,000-word text
- Large tables
- Images
- Code blocks
The estimate may be less accurate.
That’s okay.
But you should evaluate whether the optimization is producing a better experience.
32. Use It at Logical Rendering Boundaries
A strong rule is:
Apply containment to components that represent meaningful independent regions.
For example:
Article section
Product card
Dashboard widget
Comment group
Recommendation block
These are logical units.
Avoid applying it randomly to every DOM node.
That creates complexity without necessarily creating meaningful performance improvements.
33. Performance Optimization Should Follow Measurement
Before:
Apply content-visibility everywhere
do:
Measure
↓
Identify rendering bottleneck
↓
Apply optimization
↓
Measure again
Use:
- Browser DevTools
- Lighthouse
- Performance traces
- Real-device testing
- Core Web Vitals monitoring
web.dev provides guidance around modern performance measurement and specifically highlights INP as a Core Web Vital.
The browser is complicated.
Your optimization process shouldn’t be guesswork.
34. Look at the Main Thread
If a page feels slow, inspect what the main thread is doing.
You may discover:
JavaScript execution
██████████████████
Style recalculation
██████
Layout
████████
Paint
██████████
If rendering work is significant, containment can be relevant.
If JavaScript dominates:
JavaScript execution
████████████████████████████████
then content-visibility isn’t your first problem.
Fix the actual bottleneck.
35. Don’t Optimize Paint When the Problem Is JavaScript
This sounds obvious.
But frontend teams often optimize whatever technique they recently learned.
If the page spends most of its time executing JavaScript, adding CSS containment may have little impact.
Instead:
- Reduce JavaScript
- Break up long tasks
- Defer non-critical work
- Remove unnecessary third-party scripts
- Reduce client-side rendering
- Avoid expensive synchronous operations
Then revisit rendering.
36. Don’t Optimize Rendering When the Problem Is Images
If your page contains:
20 huge JPEGs
+
4 unoptimized videos
+
massive hero image
start there.
Use:
<img loading="lazy">
where appropriate.
Use responsive images.
Compress assets.
Choose appropriate formats.
content-visibility doesn’t replace asset optimization.
It solves a different problem.
37. The Architecture of a Fast Long Page
For a content-heavy page, think in layers:
HTML
↓
Semantic structure
CSS
↓
Efficient layout and containment
Images
↓
Responsive + lazy loading where appropriate
JavaScript
↓
Only necessary behavior
Rendering
↓
Defer off-screen work
Monitoring
↓
Measure real performance
No single technique is responsible for the entire experience.
38. Example: A Long SaaS Landing Page
Imagine:
Hero
↓
Social proof
↓
Feature 1
↓
Feature 2
↓
Feature 3
↓
Integrations
↓
Security
↓
Pricing
↓
Testimonials
↓
FAQ
↓
CTA
You might choose:
.page-section {
content-visibility: auto;
contain-intrinsic-size: auto 700px;
}
But be selective.
The hero is immediately visible.
There is little value in deferring it.
The first viewport should remain straightforward.
For sections far below the viewport, the potential benefit becomes more interesting.
39. Example: Documentation Website
Documentation is a particularly strong candidate.
A large documentation page may contain:
Introduction
Installation
Configuration
Authentication
Examples
API Reference
Troubleshooting
Migration Guide
FAQ
Each section can be substantial.
You could structure:
.docs-section {
content-visibility: auto;
contain-intrinsic-size: auto 800px;
}
This allows the browser to defer some rendering work while maintaining the actual document content.
For large documentation systems, this can be a useful part of a broader performance strategy.
40. Example: Product Grid
Consider:
100 products
Each card includes:
- Image
- Price
- Rating
- Description
- Buttons
- Badges
You may use:
.product-card {
content-visibility: auto;
contain-intrinsic-size: auto 400px;
}
But there’s an important distinction.
If you render all 100 products into the DOM, content-visibility can reduce some rendering work.
It does not mean you should automatically render 10,000 products.
For very large collections, virtualization may still be the better architectural choice.
41. content-visibility vs Virtualization
These are not identical.
content-visibility
Keeps the content in the DOM while allowing the browser to skip some rendering work when appropriate.
Virtualization
Usually renders only a smaller subset of a very large collection and manages what exists in the DOM.
For:
100 cards
content-visibility may be useful.
For:
100,000 rows
you likely need a more fundamental rendering strategy.
Don’t use CSS to solve a data-volume architecture problem.
42. content-visibility vs Lazy Rendering
Lazy rendering usually means:
Don't create/render this component until needed.
content-visibility: auto means:
The content exists, but the browser can skip some rendering work while it's not relevant.
Those approaches can complement each other.
For complex applications:
Data virtualization
+
Component lazy loading
+
content-visibility
+
image lazy loading
may all have roles.
But each solves a different problem.
43. Don’t Turn Performance Into a Stack of Hacks
A common frontend mistake looks like this:
Lazy load everything
+
Memoize everything
+
Virtualize everything
+
content-visibility everywhere
+
Code split everything
The result can become harder to maintain than the original application.
Every optimization adds complexity.
The correct approach is:
Measure
↓
Identify bottleneck
↓
Choose smallest useful intervention
↓
Measure
That’s sustainable performance engineering.
44. CSS Is Becoming More Capable at Performance Work
This is part of a larger shift in modern web development.
Developers once used JavaScript for many layout and rendering behaviors.
Now the platform gives browsers more information through CSS.
Containment is one example.
Container queries are another.
Modern CSS increasingly allows the browser to make better decisions about:
- Layout
- Rendering
- Component boundaries
- Visibility
- Responsiveness
That doesn’t eliminate JavaScript.
It lets JavaScript focus more on application behavior.
45. The Developer Mindset Shift
Instead of asking:
How can I make this faster with JavaScript?
ask:
What work does the browser actually need to do?
Then:
Need network optimization?
→ Optimize assets.
Need JavaScript optimization?
→ Reduce main-thread work.
Need rendering optimization?
→ Consider containment.
Need image optimization?
→ Lazy-load and resize assets.
Need DOM optimization?
→ Reduce unnecessary nodes or virtualize.
This is a much better way to approach performance.
46. A Production CSS Pattern
Here’s a practical starting point:
.section {
content-visibility: auto;
contain-intrinsic-size: auto 600px;
}
For a card:
.card {
content-visibility: auto;
contain-intrinsic-size: auto 400px;
}
For a long documentation section:
.docs-section {
content-visibility: auto;
contain-intrinsic-size: auto 800px;
}
Then measure.
Don’t assume.
47. A More Defensive Version
You can keep your performance enhancement scoped to a component class:
.performance-section {
content-visibility: auto;
contain-intrinsic-size: auto 600px;
}
Then only apply it where you’ve tested it.
This is better than:
section {
content-visibility: auto;
}
because a global selector can unexpectedly affect:
- Modals
- Navigation
- Forms
- Footers
- Interactive widgets
- Third-party components
Performance CSS should have boundaries too.
48. Browser Compatibility Still Matters
MDN currently lists content-visibility as Baseline 2024 and notes that it works across the latest devices and browser versions, while older devices and browsers may differ.
That’s encouraging for modern projects.
But progressive enhancement is still sensible.
Your page should work without relying on the property.
If the browser doesn’t support it, the content should still exist normally.
That’s one reason content-visibility is a useful enhancement rather than something your application logic should depend on.
49. Progressive Enhancement Example
You can simply write:
.section {
content-visibility: auto;
contain-intrinsic-size: auto 600px;
}
Browsers that don’t understand these properties ignore them.
The HTML still exists.
The page still works.
That’s an ideal performance enhancement.
You aren’t changing the meaning of the document.
You’re giving capable browsers additional optimization information.
50. The Myth: Unsupported Browsers Get a Broken Website
Not necessarily.
If the feature is purely an enhancement, an unsupported browser simply renders the page normally.
That’s one of the strongest reasons to prefer platform-level performance features.
Your baseline implementation remains valid.
Modern browsers receive optimization.
Older browsers receive the normal experience.
51. The Myth: More Containment Always Means Better Performance
No.
Containment changes browser behavior.
Too much containment can complicate layout or create unexpected interactions with sizing and positioning.
You need to understand the component.
Use containment where the subtree is meaningfully independent.
Don’t blindly apply every containment mechanism to every node.
Performance engineering requires judgment.
52. The Myth: content-visibility Is a Replacement for Good Page Architecture
It isn’t.
If your page has:
20,000 DOM nodes
and half of them are unnecessary, don’t celebrate because:
content-visibility: auto;
reduced some rendering work.
First ask:
Why do we have 20,000 nodes?
Sometimes the correct optimization is removing unnecessary complexity.
CSS should optimize a good architecture.
It shouldn’t disguise a bad one.
53. Accessibility Testing Checklist
After applying content-visibility, test:
Keyboard
Can you tab through interactive elements?
Focus
Can JavaScript focus an off-screen element correctly?
Find-in-page
Can the browser find text in skipped sections?
Anchors
Do #section links navigate correctly?
Screen readers
Is the content exposed as expected?
Selection
Can users select text?
Responsive layouts
Does the estimated intrinsic size create strange gaps?
Scrolling
Does the page remain stable while scrolling?
MDN’s documentation specifically notes that auto content remains available to several browser and accessibility features, but actual product testing remains important.
54. Performance Testing Checklist
Before and after implementation, compare:
- Initial render
- Main-thread activity
- Layout work
- Paint work
- Scroll performance
- Interaction responsiveness
- Layout stability
- Memory behavior
Don’t only look at Lighthouse.
Open DevTools.
Record a performance trace.
Test on a slower device.
A desktop developer machine can hide problems that users experience on real hardware.
55. Use Real Content During Testing
Don’t test with:
Lorem ipsum
Test with the actual page.
Real:
- Images
- Tables
- Code blocks
- User names
- Product descriptions
- Reviews
- Long headings
- Translations
A performance optimization can behave differently with real content.
The browser doesn’t render your design intentions.
It renders your actual DOM.
56. The Practical Decision Tree
When you see a large page, ask:
Is there a lot of off-screen content?
If no, stop.
Is that content expensive to render?
If no, stop.
Can it be divided into meaningful sections?
If yes, consider containment.
Does it have predictable approximate dimensions?
If yes, consider contain-intrinsic-size.
Does it contain expensive JavaScript or canvas work?
Consider coordinating application work with visibility.
Does it affect accessibility or navigation?
Test it.
Did performance actually improve?
Keep it.
If not, remove it.
This is a much better workflow than optimizing because a CSS feature is fashionable.
57. The Deeper Lesson: Performance Is About Work, Not Code Size
A developer might see:
100 KB CSS
and:
2 MB JavaScript
and immediately focus on bundle size.
That’s useful.
But the real question is:
How much work does the browser perform before the user can interact comfortably?
You can have:
Small files
+
Expensive execution
+
Expensive layout
+
Expensive paint
or:
Larger content
+
Efficient rendering
+
Deferred off-screen work
Performance is about the whole pipeline.
58. The Browser Is Better at Scheduling Browser Work
This is one reason native CSS capabilities are valuable.
If you use JavaScript to decide:
Should I render this section?
you need to implement the logic.
With content-visibility: auto, the browser can make the decision based on the viewport and its rendering system.
That gives the browser more control.
And the browser has information your application may not have.
59. The Resolution: Make the Browser Work Only as Hard as Necessary
The most useful way to think about content-visibility is not:
It’s a CSS speed hack.
Think:
It’s a way to tell the browser that parts of my document don’t need full rendering attention yet.
That is a much more accurate mental model.
For a long page:
Above viewport
↓
Render normally
Far below viewport
↓
Potentially skip rendering work
Approaching viewport
↓
Render when needed
That is the behavior you’re designing for.
60. How Ayushman Jena Can Apply This to Real Projects
For a developer building websites and SaaS products, content-visibility fits naturally into component architecture.
Instead of creating a generic:
PerformanceOptimization
component, think about actual boundaries:
ArticleSection
DashboardWidget
ProductCard
CommentThread
DocumentationSection
Then decide whether each component is a good candidate.
For example:
.dashboard-widget {
content-visibility: auto;
contain-intrinsic-size: auto 450px;
}
This communicates intent.
It tells another developer:
Dashboard widgets may be independently skipped when they’re not currently relevant.
That’s understandable code.
61. Build Performance Into the Component System
A mature SaaS design system shouldn’t only define:
Button
Input
Card
Modal
Table
It should also have performance-aware component patterns.
For example:
DashboardCard
↓
Accessible
Responsive
Containment-aware
Or:
LongContentSection
↓
Semantic
Responsive
content-visibility enabled
This makes performance a property of architecture rather than a last-minute patch.
62. Don’t Hide Performance Behind Abstractions
If a component uses:
content-visibility: auto;
document why.
For example:
/* Defer rendering for off-screen dashboard widgets. */
.dashboard-widget {
content-visibility: auto;
contain-intrinsic-size: auto 450px;
}
That comment may seem unnecessary.
Six months later, someone will understand why the property exists.
Performance optimizations should be explainable.
63. A Complete Example
HTML:
<main>
<section class="hero">
<h1>Build Better Websites</h1>
<p>Performance-focused web development.</p>
</section>
<section class="content-section">
<h2>Performance</h2>
<p>...</p>
</section>
<section class="content-section">
<h2>Accessibility</h2>
<p>...</p>
</section>
<section class="content-section">
<h2>SEO</h2>
<p>...</p>
</section>
<section class="content-section">
<h2>Case Studies</h2>
<p>...</p>
</section>
</main>
CSS:
.content-section {
content-visibility: auto;
contain-intrinsic-size: auto 600px;
}
The hero remains normal.
The deeper sections become candidates for skipped rendering work.
That’s simple.
And simple is good.
64. A More Advanced Example With a Chart
<section class="dashboard-widget">
<h2>Revenue</h2>
<canvas id="revenue-chart"></canvas>
</section>
.dashboard-widget {
content-visibility: auto;
contain-intrinsic-size: auto 450px;
}
Then JavaScript can use the browser’s visibility-related event to coordinate expensive rendering work where appropriate.
The architecture becomes:
CSS
↓
Controls rendering eligibility
JavaScript
↓
Controls expensive application work
Browser
↓
Coordinates rendering
This is much cleaner than continuously drawing every chart on a large dashboard.
65. Final Production Checklist
Before using content-visibility, check:
Content
- Is the page genuinely long or expensive?
- Are there meaningful independent sections?
Rendering
- Is rendering actually a bottleneck?
- Did you inspect a performance trace?
CSS
- Are you using
content-visibility: auto? - Would
contain-intrinsic-sizehelp?
Layout
- Are approximate dimensions reasonable?
- Does scrolling remain stable?
Accessibility
- Does keyboard navigation work?
- Does find-in-page work?
- Do anchors work?
- Does assistive technology still receive the content?
JavaScript
- Are expensive widgets doing unnecessary work?
- Can visibility-related state be used to pause expensive rendering?
Compatibility
- Does the site remain fully usable when the property isn’t supported?
Measurement
- Did you compare before and after?
- Did you test on a real device?
If the answer is yes, you’re using the feature thoughtfully.
Conclusion: The Fastest Rendering Work Is Often the Work You Don’t Need Yet
content-visibility is a good example of where modern frontend performance is heading.
The browser is already responsible for:
- Layout
- Painting
- Rendering
- Scrolling
- Interaction
Developers don’t always need to manually control every part of that process.
Sometimes the better approach is to give the browser useful information.
With:
content-visibility: auto;
you can allow the browser to skip rendering work for content that isn’t currently relevant.
With:
contain-intrinsic-size: auto 600px;
you can give it an approximate size to help maintain layout stability while that content isn’t being fully rendered. MDN specifically recommends this mechanism as a way to reserve space for contained content and reduce layout shifts or scrollbar movement.
And with the related visibility-state event, applications can potentially coordinate expensive work such as canvas rendering with whether content actually needs to be rendered.
But the most important lesson isn’t the syntax.
It’s the way you approach performance.
Don’t optimize blindly.
Don’t add CSS properties because they’re new.
Don’t use content-visibility to hide a fundamentally bad architecture.
Don’t use it as a substitute for reducing JavaScript, optimizing images, or fixing expensive application logic.
Instead:
Measure
↓
Find the real bottleneck
↓
Identify expensive off-screen content
↓
Create meaningful component boundaries
↓
Use content-visibility where appropriate
↓
Add intrinsic size estimates
↓
Test accessibility
↓
Measure again
That’s a professional performance workflow.
For Ayushman Jena, this kind of browser-level optimization is also a useful reminder that modern web development isn’t always about adding another library.
Sometimes the biggest improvement comes from understanding what the browser already knows how to do.
A long page doesn’t necessarily need to render every section with equal urgency.
A dashboard doesn’t necessarily need every chart working at full intensity before the user reaches it.
A documentation page doesn’t necessarily need every code block and section painted immediately.
The browser can often do less work now and more work later.
And if the user never reaches the bottom of the page?
That deferred work may never become necessary.
That’s the real idea behind content-visibility.
Don’t make the browser work harder than the user experience requires.
When applied carefully, content-visibility turns that principle into a single CSS declaration, backed by the browser’s own rendering engine rather than another JavaScript optimization layer.
And that is exactly the kind of web-platform feature developers should learn to recognize: small syntax, meaningful architectural consequences, and no unnecessary framework required.