Skip to content

Commit de6b53a

Browse files
authored
core: rename preload-lcp-image to prioritize-lcp-image (#14761)
1 parent 0b8c63d commit de6b53a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+88
-362
lines changed

cli/test/smokehouse/test-definitions/dobetterweb.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ const expectations = {
536536
],
537537
},
538538
},
539-
'preload-lcp-image': {
539+
'prioritize-lcp-image': {
540540
score: 1,
541541
numericValue: 0,
542542
details: {

cli/test/smokehouse/test-definitions/perf-trace-elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const expectations = {
191191
},
192192
},
193193
},
194-
'preload-lcp-image': {
194+
'prioritize-lcp-image': {
195195
score: 1,
196196
numericValue: 0,
197197
details: {

core/audits/preload-lcp-image.js renamed to core/audits/prioritize-lcp-image.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
2727
* @typedef {Array<{url: string, initiatorType: string}>} InitiatorPath
2828
*/
2929

30-
class PreloadLCPImageAudit extends Audit {
30+
class PrioritizeLcpImage extends Audit {
3131
/**
3232
* @return {LH.Audit.Meta}
3333
*/
3434
static get meta() {
3535
return {
36-
id: 'preload-lcp-image',
36+
id: 'prioritize-lcp-image',
3737
title: str_(UIStrings.title),
3838
description: str_(UIStrings.description),
3939
supportedModes: ['navigation'],
@@ -92,11 +92,11 @@ class PreloadLCPImageAudit extends Audit {
9292
*/
9393
static getLCPNodeToPreload(mainResource, graph, lcpUrl) {
9494
if (!lcpUrl) return {};
95-
const {lcpNode, path} = PreloadLCPImageAudit.findLCPNode(graph, lcpUrl);
95+
const {lcpNode, path} = PrioritizeLcpImage.findLCPNode(graph, lcpUrl);
9696
if (!lcpNode || !path) return {};
9797

9898
// eslint-disable-next-line max-len
99-
const shouldPreload = PreloadLCPImageAudit.shouldPreloadRequest(lcpNode.record, mainResource, path);
99+
const shouldPreload = PrioritizeLcpImage.shouldPreloadRequest(lcpNode.record, mainResource, path);
100100
const lcpNodeToPreload = shouldPreload ? lcpNode : undefined;
101101

102102
const initiatorPath = [
@@ -230,8 +230,8 @@ class PreloadLCPImageAudit extends Audit {
230230
*/
231231
static async audit(artifacts, context) {
232232
const gatherContext = artifacts.GatherContext;
233-
const trace = artifacts.traces[PreloadLCPImageAudit.DEFAULT_PASS];
234-
const devtoolsLog = artifacts.devtoolsLogs[PreloadLCPImageAudit.DEFAULT_PASS];
233+
const trace = artifacts.traces[PrioritizeLcpImage.DEFAULT_PASS];
234+
const devtoolsLog = artifacts.devtoolsLogs[PrioritizeLcpImage.DEFAULT_PASS];
235235
const URL = artifacts.URL;
236236
const metricData = {trace, devtoolsLog, gatherContext, settings: context.settings, URL};
237237
const lcpElement = artifacts.TraceElements
@@ -248,13 +248,13 @@ class PreloadLCPImageAudit extends Audit {
248248
LoadSimulator.request({devtoolsLog, settings: context.settings}, context),
249249
]);
250250

251-
const lcpUrl = PreloadLCPImageAudit.getLcpUrl(trace, processedNavigation);
251+
const lcpUrl = PrioritizeLcpImage.getLcpUrl(trace, processedNavigation);
252252
const graph = lanternLCP.pessimisticGraph;
253253
// eslint-disable-next-line max-len
254-
const {lcpNodeToPreload, initiatorPath} = PreloadLCPImageAudit.getLCPNodeToPreload(mainResource, graph, lcpUrl);
254+
const {lcpNodeToPreload, initiatorPath} = PrioritizeLcpImage.getLCPNodeToPreload(mainResource, graph, lcpUrl);
255255

256256
const {results, wastedMs} =
257-
PreloadLCPImageAudit.computeWasteWithGraph(lcpElement, lcpNodeToPreload, graph, simulator);
257+
PrioritizeLcpImage.computeWasteWithGraph(lcpElement, lcpNodeToPreload, graph, simulator);
258258

259259
/** @type {LH.Audit.Details.Opportunity['headings']} */
260260
const headings = [
@@ -286,5 +286,5 @@ class PreloadLCPImageAudit extends Audit {
286286
}
287287
}
288288

289-
export default PreloadLCPImageAudit;
289+
export default PrioritizeLcpImage;
290290
export {UIStrings};

core/config/default-config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ const defaultConfig = {
227227
'non-composited-animations',
228228
'unsized-images',
229229
'valid-source-maps',
230-
'preload-lcp-image',
230+
'prioritize-lcp-image',
231231
'csp-xss',
232232
'script-treemap-data',
233233
'manual/pwa-cross-browser',
@@ -446,7 +446,7 @@ const defaultConfig = {
446446
{id: 'efficient-animated-content', weight: 0},
447447
{id: 'duplicated-javascript', weight: 0},
448448
{id: 'legacy-javascript', weight: 0},
449-
{id: 'preload-lcp-image', weight: 0},
449+
{id: 'prioritize-lcp-image', weight: 0},
450450
{id: 'total-byte-weight', weight: 0},
451451
{id: 'uses-long-cache-ttl', weight: 0},
452452
{id: 'dom-size', weight: 0},

core/config/metrics-to-audits.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const fcpRelevantAudits = [
2222
const lcpRelevantAudits = [
2323
...fcpRelevantAudits,
2424
'largest-contentful-paint-element',
25-
'preload-lcp-image',
25+
'prioritize-lcp-image',
2626
'unused-javascript',
2727
'efficient-animated-content',
2828
'total-byte-weight',

core/test/audits/preload-lcp-image-test.js renamed to core/test/audits/prioritize-lcp-image-test.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
55
*/
66

7-
import PreloadLCPImage from '../../audits/preload-lcp-image.js';
7+
import PrioritizeLcpImage from '../../audits/prioritize-lcp-image.js';
88
import {networkRecordsToDevtoolsLog} from '../network-records-to-devtools-log.js';
99
import {createTestTrace} from '../create-test-trace.js';
1010

@@ -13,17 +13,19 @@ const mainDocumentNodeUrl = 'http://www.example.com:3000';
1313
const scriptNodeUrl = 'http://www.example.com/script.js';
1414
const imageUrl = 'http://www.example.com/image.png';
1515

16-
describe('Performance: preload-lcp audit', () => {
16+
describe('Performance: prioritize-lcp-image audit', () => {
1717
const mockArtifacts = (networkRecords, finalDisplayedUrl) => {
1818
return {
1919
GatherContext: {gatherMode: 'navigation'},
2020
traces: {
21-
[PreloadLCPImage.DEFAULT_PASS]: createTestTrace({
21+
[PrioritizeLcpImage.DEFAULT_PASS]: createTestTrace({
2222
traceEnd: 6e3,
2323
largestContentfulPaint: 45e2,
2424
}),
2525
},
26-
devtoolsLogs: {[PreloadLCPImage.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords)},
26+
devtoolsLogs: {
27+
[PrioritizeLcpImage.DEFAULT_PASS]: networkRecordsToDevtoolsLog(networkRecords),
28+
},
2729
URL: {
2830
requestedUrl: finalDisplayedUrl,
2931
mainDocumentUrl: finalDisplayedUrl,
@@ -92,7 +94,7 @@ describe('Performance: preload-lcp audit', () => {
9294
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
9395
artifacts.TraceElements = [];
9496
const context = {settings: {}, computedCache: new Map()};
95-
const result = await PreloadLCPImage.audit(artifacts, context);
97+
const result = await PrioritizeLcpImage.audit(artifacts, context);
9698
expect(result).toEqual({
9799
score: null,
98100
notApplicable: true,
@@ -104,7 +106,7 @@ describe('Performance: preload-lcp audit', () => {
104106
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
105107
artifacts.TraceElements[0].type = 'text';
106108
const context = {settings: {}, computedCache: new Map()};
107-
const result = await PreloadLCPImage.audit(artifacts, context);
109+
const result = await PrioritizeLcpImage.audit(artifacts, context);
108110
expect(result).toEqual({
109111
score: null,
110112
notApplicable: true,
@@ -121,7 +123,7 @@ describe('Performance: preload-lcp audit', () => {
121123
imagePaintEvent.args.data.DOMNodeId = 1729;
122124

123125
const context = {settings: {}, computedCache: new Map()};
124-
const results = await PreloadLCPImage.audit(artifacts, context);
126+
const results = await PrioritizeLcpImage.audit(artifacts, context);
125127
expect(results.score).toEqual(1);
126128
expect(results.details.overallSavingsMs).toEqual(0);
127129
expect(results.details.items).toHaveLength(0);
@@ -132,7 +134,7 @@ describe('Performance: preload-lcp audit', () => {
132134
networkRecords[3].isLinkPreload = true;
133135
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
134136
const context = {settings: {}, computedCache: new Map()};
135-
const results = await PreloadLCPImage.audit(artifacts, context);
137+
const results = await PrioritizeLcpImage.audit(artifacts, context);
136138
expect(results.score).toEqual(1);
137139
expect(results.details.overallSavingsMs).toEqual(0);
138140
expect(results.details.items).toHaveLength(0);
@@ -143,7 +145,7 @@ describe('Performance: preload-lcp audit', () => {
143145
networkRecords[3].protocol = 'data';
144146
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
145147
const context = {settings: {}, computedCache: new Map()};
146-
const results = await PreloadLCPImage.audit(artifacts, context);
148+
const results = await PrioritizeLcpImage.audit(artifacts, context);
147149
expect(results.score).toEqual(1);
148150
expect(results.details.overallSavingsMs).toEqual(0);
149151
expect(results.details.items).toHaveLength(0);
@@ -153,7 +155,7 @@ describe('Performance: preload-lcp audit', () => {
153155
const networkRecords = mockNetworkRecords();
154156
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
155157
const context = {settings: {}, computedCache: new Map()};
156-
const results = await PreloadLCPImage.audit(artifacts, context);
158+
const results = await PrioritizeLcpImage.audit(artifacts, context);
157159
expect(results.numericValue).toEqual(180);
158160
expect(results.details.overallSavingsMs).toEqual(180);
159161
expect(results.details.items[0].url).toEqual(imageUrl);
@@ -175,7 +177,7 @@ describe('Performance: preload-lcp audit', () => {
175177
networkRecords[3].transferSize = 5 * 1000 * 1000;
176178
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
177179
const context = {settings: {}, computedCache: new Map()};
178-
const results = await PreloadLCPImage.audit(artifacts, context);
180+
const results = await PrioritizeLcpImage.audit(artifacts, context);
179181
expect(results.numericValue).toEqual(30);
180182
expect(results.details.overallSavingsMs).toEqual(30);
181183
expect(results.details.items[0].url).toEqual(imageUrl);
@@ -187,7 +189,7 @@ describe('Performance: preload-lcp audit', () => {
187189
networkRecords[2].transferSize = 2 * 1000 * 1000;
188190
const artifacts = mockArtifacts(networkRecords, mainDocumentNodeUrl);
189191
const context = {settings: {}, computedCache: new Map()};
190-
const results = await PreloadLCPImage.audit(artifacts, context);
192+
const results = await PrioritizeLcpImage.audit(artifacts, context);
191193
expect(results.numericValue).toEqual(30);
192194
expect(results.details.overallSavingsMs).toEqual(30);
193195
expect(results.details.items[0].url).toEqual(imageUrl);

0 commit comments

Comments
 (0)