Skip to content

Commit 9e0bf01

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored andcommitted
RPP: improve LCP fetchpriority text
This CL updates the LCPDiscovery component to show specific text for when fetchpriority should be applied to make it clear to the user what we are suggesting. Fixed: 394009056 Change-Id: I6588b3ed3b7327c94cd84f052370a3a89595adf5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6235031 Reviewed-by: Andres Olivares <[email protected]> Commit-Queue: Andres Olivares <[email protected]> Auto-Submit: Jack Franklin <[email protected]>
1 parent 71de1f6 commit 9e0bf01

File tree

7 files changed

+35
-2
lines changed

7 files changed

+35
-2
lines changed

front_end/models/trace/insights/LCPDiscovery.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,24 @@ describeWithEnvironment('LCPDiscovery', function() {
1818
assert.isTrue(checklist.eagerlyLoaded.value);
1919
});
2020

21+
it('uses the fetchpriority=high text when the image has fetchpriority set', async () => {
22+
const {data, insights} = await processTrace(this, 'lcp-fetchpriority-high.json.gz');
23+
const firstNav = getFirstOrError(data.Meta.navigationsByNavigationId.values());
24+
const insight = getInsightOrError('LCPDiscovery', insights, firstNav);
25+
assert.isOk(insight.checklist);
26+
assert.isTrue(insight.checklist.priorityHinted.value);
27+
assert.strictEqual(insight.checklist.priorityHinted.label, 'fetchpriority=high applied');
28+
});
29+
30+
it('uses the should apply fetchpriority=high text when the image does not fetchpriority set', async () => {
31+
const {data, insights} = await processTrace(this, 'web-dev-with-commit.json.gz');
32+
const firstNav = getFirstOrError(data.Meta.navigationsByNavigationId.values());
33+
const insight = getInsightOrError('LCPDiscovery', insights, firstNav);
34+
assert.isOk(insight.checklist);
35+
assert.isFalse(insight.checklist.priorityHinted.value);
36+
assert.strictEqual(insight.checklist.priorityHinted.label, 'fetchpriority=high should be applied');
37+
});
38+
2139
it('calculates the LCP optimal time as the document request download start time', async () => {
2240
const {data, insights} = await processTrace(this, 'web-dev-with-commit.json.gz');
2341
const firstNav = getFirstOrError(data.Meta.navigationsByNavigationId.values());

front_end/models/trace/insights/LCPDiscovery.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ export const UIStrings = {
3636
* @description Text to tell the user that a fetchpriority property value of "high" is applied to the LCP request.
3737
*/
3838
fetchPriorityApplied: 'fetchpriority=high applied',
39+
/**
40+
* @description Text to tell the user that a fetchpriority property value of "high" should be applied to the LCP request.
41+
*/
42+
fetchPriorityShouldBeApplied: 'fetchpriority=high should be applied',
3943
/**
4044
* @description Text to tell the user that the LCP request is discoverable in the initial document.
4145
*/
@@ -136,12 +140,18 @@ export function generateInsight(
136140
Helpers.Timing.milliToMicro(docRequest.args.data.timing.receiveHeadersStart) :
137141
undefined;
138142

143+
const priorityHintFound = imageFetchPriorityHint === 'high';
144+
139145
return finalize({
140146
lcpEvent,
141147
lcpRequest,
142148
earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.Micro(earliestDiscoveryTime) : undefined,
143149
checklist: {
144-
priorityHinted: {label: i18nString(UIStrings.fetchPriorityApplied), value: imageFetchPriorityHint === 'high'},
150+
priorityHinted: {
151+
label: priorityHintFound ? i18nString(UIStrings.fetchPriorityApplied) :
152+
i18nString(UIStrings.fetchPriorityShouldBeApplied),
153+
value: priorityHintFound
154+
},
145155
requestDiscoverable: {label: i18nString(UIStrings.requestDiscoverable), value: imgPreloadedOrFoundInHTML},
146156
eagerlyLoaded: {label: i18nString(UIStrings.lazyLoadNotApplied), value: imageLoadingAttr !== 'lazy'},
147157
},

front_end/panels/timeline/components/insights/Checklist.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class Checklist extends HTMLElement {
9292
<ul>
9393
${Object.values(this.#checklist).map(check => html`<li>
9494
${this.#getIcon(check)}
95-
<span>${check.label}</span>
95+
<span data-checklist-label>${check.label}</span>
9696
</li>`)}
9797
</ul>`,
9898
this.#shadow, {host: this});

front_end/panels/timeline/fixtures/traces/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ copy_to_gen("traces") {
4848
"large-layout-small-recalc.json.gz",
4949
"large-profile.cpuprofile.gz",
5050
"large-recalc-style.json.gz",
51+
"lcp-fetchpriority-high.json.gz",
5152
"lcp-images-rasterizer.json.gz",
5253
"lcp-images.json.gz",
5354
"lcp-late-paint-event.json.gz",

front_end/panels/timeline/fixtures/traces/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,7 @@ A trace generated from crrev.com/c/6197645 (January 2025), which changed the for
254254
### dom-size-overlap
255255

256256
Trace containing a cross-origin navigation where DOM size events from the pre-navigation page are emitted *after* the navigation event.
257+
258+
### lcp-fetchpriority-high
259+
260+
A page that loads an image as the LCP resource with fetchpriority=high set.
Binary file not shown.
916 Bytes
Loading

0 commit comments

Comments
 (0)