Skip to content

Instantly share code, notes, and snippets.

@mkczarkowski
Created February 21, 2021 17:59
Show Gist options
  • Save mkczarkowski/99118a49e3e3a7501c6421d3f488f6a9 to your computer and use it in GitHub Desktop.
Save mkczarkowski/99118a49e3e3a7501c6421d3f488f6a9 to your computer and use it in GitHub Desktop.
This script let you detect and measure LCP on your website.
new PerformanceObserver((entryList) => {
for (const entry of entryList.getEntries()) {
console.log("LCP candidate:", entry.startTime, entry);
}
}).observe({ type: "largest-contentful-paint", buffered: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment