Function getTTFB

  • Gets the time to first byte (TTFB) of a web page using the Performance API. The TTFB is the time it takes for the first byte of the response to be received by the browser.

    Usage:

    getTTFB().then(
    res => {
    console.log(`TTFB: ${res}`);
    }
    );

    Output:

    TTFB: 123
    

    Returns Promise<number>

    The TTFB in milliseconds, or 0 if the navigation timing information is not available.