Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Dec 10, 2024
1 parent 4cd4524 commit 388e65d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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))

Expand Down
9 changes: 5 additions & 4 deletions src/attribution/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand Down
9 changes: 5 additions & 4 deletions src/onTTFB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 388e65d

Please sign in to comment.