Skip to content

Commit

Permalink
Remove documentStart
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Nov 18, 2024
1 parent a9e2d23 commit 7e85484
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 33 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- **[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 and `documentDuration` to measure Early Hints better ([#566](https://github.com/GoogleChrome/web-vitals/pull/566))
- **[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
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1009,16 +1009,6 @@ export interface TTFBAttribution {
* processing time.
*/
requestDuration: number;
/**
* The total time, after TTFB, after which the document started to be
* received (i.e. when the document HTTP headers start to artive).
* This will only be non-zero for servers using Early Hints and where
* browsers support sending this additional timing. It is the time between
* the Early Hints first response (TTFB) and when the actual document
* response started and is useful to understand how much later the document
* TTFB is from the actual TTFB.
*/
documentDuration: number;
/**
* The `navigation` entry of the current page, which is useful for diagnosing
* general page load issues. This can be used to access `serverTiming` for
Expand Down
10 changes: 9 additions & 1 deletion src/attribution/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ const attributeLCP = (metric: LCPMetric): LCPMetricWithAttribution => {
.getEntriesByType('resource')
.filter((e) => e.name === lcpEntry.url)[0];

const ttfb = Math.max(0, navigationEntry.responseStart - activationStart);
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
navigationEntry.firstInterimResponseStart ??
navigationEntry.responseStart - activationStart,
);

const lcpRequestStart = Math.max(
ttfb,
Expand Down
7 changes: 0 additions & 7 deletions src/attribution/onTTFB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const attributeTTFB = (metric: TTFBMetric): TTFBMetricWithAttribution => {
dnsDuration: 0,
connectionDuration: 0,
requestDuration: 0,
documentDuration: 0,
};

if (metric.entries.length) {
Expand Down Expand Up @@ -58,11 +57,6 @@ const attributeTTFB = (metric: TTFBMetric): TTFBMetricWithAttribution => {
0,
);

// Fallback to responseStart for finalResponseHeadersStart
const finalResponseHeadersStart =
(navigationEntry.finalResponseHeadersStart ??
navigationEntry.responseStart) - activationStart;

attribution = {
waitingDuration: waitEnd,
cacheDuration: dnsStart - waitEnd,
Expand All @@ -75,7 +69,6 @@ const attributeTTFB = (metric: TTFBMetric): TTFBMetricWithAttribution => {
// service worker controlled requests were connectStart and connectEnd
// are the same.
requestDuration: metric.value - connectEnd,
documentDuration: finalResponseHeadersStart - metric.value,
navigationEntry: navigationEntry,
};
}
Expand Down
8 changes: 4 additions & 4 deletions src/onTTFB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ export const onTTFB = (
const navigationEntry = getNavigationEntry();

if (navigationEntry) {
// Form Chrome 115 until Chrome 132 (with flags), 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, 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
const responseStart =
navigationEntry.firstInterimResponseStart ||
navigationEntry.responseStart;
Expand Down
10 changes: 0 additions & 10 deletions src/types/ttfb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,6 @@ export interface TTFBAttribution {
* processing time.
*/
requestDuration: number;
/**
* The total time, after TTFB, after which the document started to be
* received (i.e. when the document HTTP headers start to artive).
* This will only be non-zero for servers using Early Hints and where
* browsers support sending this additional timing. It is the time between
* the Early Hints first response (TTFB) and when the actual document
* response started and is useful to understand how much later the document
* TTFB is from the actual TTFB.
*/
documentDuration: number;
/**
* The `navigation` entry of the current page, which is useful for diagnosing
* general page load issues. This can be used to access `serverTiming` for
Expand Down

0 comments on commit 7e85484

Please sign in to comment.