866ai

How CSS content-visibility Works and How It Can Improve Rendering Performance

· 1 次浏览 ·来源: freeCodeCamp
What happens when a page has 150 content-heavy cards, but the user can only see the first few? You might expect the browser to only worry about what's currently visible. But this isn't exactly what happens. Content can be thousands of pixels below the viewport, and the browser may still have rendering work to do for it. So I wanted to try something. What if we could basically tell the browser: You don't need to render all of this right now. Skip the work for content the user can't see yet....

What happens when a page has 150 content-heavy cards, but the user can only see the first few? You might expect the browser to only worry about what's currently visible. But this isn't exactly what happens. Content can be thousands of pixels below the viewport, and the browser may still have rendering work to do for it. So I wanted to try something. What if we could basically tell the browser: You don't need to render all of this right now. Skip the work for content the user can't see yet....

What happens when a page has 150 content-heavy cards, but the user can only see the first few? You might expect the browser to only worry about what's currently visible. But this isn't exactly what happens. Content can be thousands of pixels below the viewport, and the browser may still have rendering work to do for it. So I wanted to try something. What if we could basically tell the browser: You don't need to render all of this right now. Skip the work for content the user can't see yet....