Skip to content

Instantly share code, notes, and snippets.

@danieltxok
Created February 17, 2021 11:21
Show Gist options
  • Save danieltxok/5a2a23b620d3f320d30442b8cbe4c919 to your computer and use it in GitHub Desktop.
Save danieltxok/5a2a23b620d3f320d30442b8cbe4c919 to your computer and use it in GitHub Desktop.
LCP Bookmarklet
javascript:
new PerformanceObserver((entryList)=>{
for (const entry of entryList.getEntries()) {
let consoleGroup = `%cLCP candidate: ${Math.round(entry.startTime)}ms`;
let styles = '';
if (entry.startTime >= 2500) {
styles = 'color: red;';
}
console.group(consoleGroup, styles);
console.log('Element:', entry.element);
console.groupEnd(consoleGroup);
}
}
).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