diff --git a/CHANGELOG.md b/CHANGELOG.md index 722cf1b7..f66bc473 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,14 @@ # Changelog +### v5.0.0-rc.1 (???) + +- **[BREAKING]** Add interoperable TTFB to measure Early Hints consistently ([#566](https://github.com/GoogleChrome/web-vitals/pull/566)) + ### v5.0.0-rc.0 (2024-10-03) - **[BREAKING]** Remove the deprecated `onFID()` function ([#519](https://github.com/GoogleChrome/web-vitals/pull/519)) - **[BREAKING]** Change browser support policy to Baseline Widely Available ([#525](https://github.com/GoogleChrome/web-vitals/pull/525)) - **[BREAKING]** Sort the classes that appear in attribution selectors to reduce cardinality ([#518](https://github.com/GoogleChrome/web-vitals/pull/518)) -- **[BREAKING]** Add interoperable TTFB to measure Early Hints consistently ([#566](https://github.com/GoogleChrome/web-vitals/pull/566)) - Cap INP breakdowns to INP duration ([#528](https://github.com/GoogleChrome/web-vitals/pull/528)) - Cap LCP load duration to LCP time ([#527](https://github.com/GoogleChrome/web-vitals/pull/527)) diff --git a/src/attribution/onLCP.ts b/src/attribution/onLCP.ts index 1b3ad32f..43f03a29 100644 --- a/src/attribution/onLCP.ts +++ b/src/attribution/onLCP.ts @@ -47,10 +47,11 @@ const attributeLCP = (metric: LCPMetric): LCPMetricWithAttribution => { const ttfb = Math.max( 0, - // From Chrome 115 until, Chrome reported responseStart as the document - // bytes, rather than Early Hint bytes. Prefer the Early Hint bytes - // (firstInterimResponseStart) for consistency with other browers, if - // non-zero + // From Chrome 115 until 133, Chrome reported responseStart as the + // document bytes, rather than Early Hint bytes. Prefer the Early Hint + // bytes (firstInterimResponseStart) for consistency with other + // browers, but only if non-zero (so use || rather than ??) as zero + // indicates no early hints. navigationEntry.firstInterimResponseStart || navigationEntry.responseStart - activationStart, ); diff --git a/src/onTTFB.ts b/src/onTTFB.ts index 47e6801b..9a87febf 100644 --- a/src/onTTFB.ts +++ b/src/onTTFB.ts @@ -71,10 +71,11 @@ export const onTTFB = ( const navigationEntry = getNavigationEntry(); if (navigationEntry) { - // From Chrome 115 until, Chrome reported responseStart as the document - // bytes, rather than Early Hint bytes. Prefer the Early Hint bytes - // (firstInterimResponseStart) for consistency with other browers, if - // non-zero + // From Chrome 115 until 133, Chrome reported responseStart as the + // document bytes, rather than Early Hint bytes. Prefer the Early Hint + // bytes (firstInterimResponseStart) for consistency with other + // browers, but only if non-zero (so use || rather than ??) as zero + // indicates no early hints. const responseStart = navigationEntry.firstInterimResponseStart || navigationEntry.responseStart; diff --git a/src/types.ts b/src/types.ts index fb00b6cf..2e21636d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -56,7 +56,7 @@ declare global { interface PerformanceNavigationTiming { // https://wicg.github.io/nav-speculation/prerendering.html#performance-navigation-timing-extension activationStart?: number; - // Early Hints support + // https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-firstinterimresponsestart firstInterimResponseStart?: number; finalResponseHeadersStart?: number; }