Skip to content

Commit

Permalink
Cap LCP download time
Browse files Browse the repository at this point in the history
  • Loading branch information
tunetheweb committed Aug 30, 2024
1 parent 9b93251 commit 2e3bb83
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/attribution/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ const attributeLCP = (metric: LCPMetric): LCPMetricWithAttribution => {
activationStart
: 0,
);
const lcpResponseEnd = Math.max(
lcpRequestStart,
lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0,
const lcpResponseEnd = Math.min(
Math.max(
lcpRequestStart,
lcpResourceEntry ? lcpResourceEntry.responseEnd - activationStart : 0,
),
// Cap at LCP time (videos continue downloading after LCP for example)
lcpEntry.startTime - activationStart,
);
const lcpRenderTime = Math.max(
lcpResponseEnd,
Expand Down

0 comments on commit 2e3bb83

Please sign in to comment.