Gets the Cumulative Layout Shift (CLS) score of a web page using the Performance API. The CLS score is a measure of how much the page layout shifts during loading.
Usage:
getCLS().then( res => { console.log(`CLS: ${res}`); }); Copy
getCLS().then( res => { console.log(`CLS: ${res}`); });
Output:
CLS: 123 Copy
CLS: 123
A promise that resolves with the CLS score, or 0 if the 'layout-shift' entry type is not supported.
Gets the Cumulative Layout Shift (CLS) score of a web page using the Performance API. The CLS score is a measure of how much the page layout shifts during loading.
Usage:
Output: