Whitepaper → https://w3c.github.io/largest-contentful-paint/
Largest Contentful Paint (LCP) aims to be a new page-load metric that:
- better correlates with user experience than the existing page-load metrics
- is easy to understand and reason about
- reduces the chance of gaming
<img src="large_image.jpg">
<p id='large-paragraph'>This is large body of text.</p>
...
<script>
const observer = new PerformanceObserver((list) => {
let perfEntries = list.getEntries();
let lastEntry = perfEntries[perfEntries.length - 1];
// Process the latest candidate for largest contentful paint
});
observer.observe({entryTypes: ['largest-contentful-paint']});
</script>