Function getCLS

  • 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}`);
    }
    );

    Output:

    CLS: 123
    

    Returns Promise<number>

    A promise that resolves with the CLS score, or 0 if the 'layout-shift' entry type is not supported.