Gets the largest contentful paint (LCP) time of a web page using the Performance API. The LCP time is the time it takes for the largest piece of content to be painted on the screen.
Usage:
getLCP().then( res => { console.log(`LCP: ${res}`); }); Copy
getLCP().then( res => { console.log(`LCP: ${res}`); });
Output:
LCP: 123 Copy
LCP: 123
A promise that resolves with the LCP time in milliseconds, or 0 if the 'largest-contentful-paint' entry type is not supported.
Gets the largest contentful paint (LCP) time of a web page using the Performance API. The LCP time is the time it takes for the largest piece of content to be painted on the screen.
Usage:
Output: