Skip to content

Commit

Permalink
Rename resourceLoadTime to resourceLoadDuration (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton authored Mar 29, 2024
1 parent be20a19 commit 9a20b45
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ interface LCPAttribution {
* otherwise 0). See [Optimize LCP](https://web.dev/articles/optimize-lcp) for
* details.
*/
resourceLoadTime: number;
resourceLoadDuration: number;
/**
* The delta between when the LCP resource finishes loading until the LCP
* element is fully rendered. See [Optimize
Expand Down
4 changes: 2 additions & 2 deletions src/attribution/onLCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const attributeLCP = (metric: LCPMetric) => {
element: getSelector(lcpEntry.element),
timeToFirstByte: ttfb,
resourceLoadDelay: lcpRequestStart - ttfb,
resourceLoadTime: lcpResponseEnd - lcpRequestStart,
resourceLoadDuration: lcpResponseEnd - lcpRequestStart,
elementRenderDelay: lcpRenderTime - lcpResponseEnd,
navigationEntry,
lcpEntry,
Expand All @@ -84,7 +84,7 @@ const attributeLCP = (metric: LCPMetric) => {
(metric as LCPMetricWithAttribution).attribution = {
timeToFirstByte: 0,
resourceLoadDelay: 0,
resourceLoadTime: 0,
resourceLoadDuration: 0,
elementRenderDelay: metric.value,
};
};
Expand Down
2 changes: 1 addition & 1 deletion src/types/lcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface LCPAttribution {
* otherwise 0). See [Optimize LCP](https://web.dev/articles/optimize-lcp) for
* details.
*/
resourceLoadTime: number;
resourceLoadDuration: number;
/**
* The delta between when the LCP resource finishes loading until the LCP
* element is fully rendered. See [Optimize
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/onLCP-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ describe('onLCP()', async function () {
assert.equal(
lcp.attribution.timeToFirstByte +
lcp.attribution.resourceLoadDelay +
lcp.attribution.resourceLoadTime +
lcp.attribution.resourceLoadDuration +
lcp.attribution.elementRenderDelay,
lcp.value,
);
Expand Down Expand Up @@ -514,7 +514,7 @@ describe('onLCP()', async function () {
assert.equal(
lcp.attribution.timeToFirstByte +
lcp.attribution.resourceLoadDelay +
lcp.attribution.resourceLoadTime +
lcp.attribution.resourceLoadDuration +
lcp.attribution.elementRenderDelay,
lcp.value,
);
Expand Down Expand Up @@ -568,7 +568,7 @@ describe('onLCP()', async function () {
);

assert.equal(
lcp.attribution.resourceLoadTime,
lcp.attribution.resourceLoadDuration,
Math.max(0, lcpResEntry.responseEnd - navEntry.activationStart) -
Math.max(0, lcpResEntry.requestStart - navEntry.activationStart),
);
Expand All @@ -583,7 +583,7 @@ describe('onLCP()', async function () {
assert.equal(
lcp.attribution.timeToFirstByte +
lcp.attribution.resourceLoadDelay +
lcp.attribution.resourceLoadTime +
lcp.attribution.resourceLoadDuration +
lcp.attribution.elementRenderDelay,
lcp.value,
);
Expand Down Expand Up @@ -614,11 +614,11 @@ describe('onLCP()', async function () {
assert.equal(lcp.attribution.url, undefined);
assert.equal(lcp.attribution.element, 'html>body>main>h1');
assert.equal(lcp.attribution.resourceLoadDelay, 0);
assert.equal(lcp.attribution.resourceLoadTime, 0);
assert.equal(lcp.attribution.resourceLoadDuration, 0);
assert.equal(
lcp.attribution.timeToFirstByte +
lcp.attribution.resourceLoadDelay +
lcp.attribution.resourceLoadTime +
lcp.attribution.resourceLoadDuration +
lcp.attribution.elementRenderDelay,
lcp.value,
);
Expand Down Expand Up @@ -664,7 +664,7 @@ describe('onLCP()', async function () {
assert.equal(lcp2.attribution.element, undefined);
assert.equal(lcp2.attribution.timeToFirstByte, 0);
assert.equal(lcp2.attribution.resourceLoadDelay, 0);
assert.equal(lcp2.attribution.resourceLoadTime, 0);
assert.equal(lcp2.attribution.resourceLoadDuration, 0);
assert.equal(lcp2.attribution.elementRenderDelay, lcp2.value);
assert.equal(lcp2.attribution.navigationEntry, undefined);
assert.equal(lcp2.attribution.lcpResourceEntry, undefined);
Expand Down

0 comments on commit 9a20b45

Please sign in to comment.