lighthouse 11.4.0-dev.20231219 → 11.4.0-dev.20231221

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,15 +6,16 @@ declare class RenderBlockingResources extends Audit {
6
6
  /**
7
7
  * @param {LH.Artifacts} artifacts
8
8
  * @param {LH.Audit.Context} context
9
- * @return {Promise<{wastedMs: number, results: Array<{url: string, totalBytes: number, wastedMs: number}>}>}
9
+ * @return {Promise<{fcpWastedMs: number, lcpWastedMs: number, results: Array<{url: string, totalBytes: number, wastedMs: number}>}>}
10
10
  */
11
11
  static computeResults(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<{
12
- wastedMs: number;
13
- results: {
12
+ fcpWastedMs: number;
13
+ lcpWastedMs: number;
14
+ results: Array<{
14
15
  url: string;
15
16
  totalBytes: number;
16
17
  wastedMs: number;
17
- }[];
18
+ }>;
18
19
  }>;
19
20
  /**
20
21
  * Estimates how much faster this page would reach FCP if we inlined all the used CSS from the
@@ -17,6 +17,8 @@ import {NetworkRequest} from '../../lib/network-request.js';
17
17
  import {ProcessedNavigation} from '../../computed/processed-navigation.js';
18
18
  import {LoadSimulator} from '../../computed/load-simulator.js';
19
19
  import {FirstContentfulPaint} from '../../computed/metrics/first-contentful-paint.js';
20
+ import {LCPImageRecord} from '../../computed/lcp-image-record.js';
21
+
20
22
 
21
23
  /** @typedef {import('../../lib/dependency-graph/simulator/simulator').Simulator} Simulator */
22
24
  /** @typedef {import('../../lib/dependency-graph/base-node.js').Node} Node */
@@ -125,7 +127,7 @@ class RenderBlockingResources extends Audit {
125
127
  /**
126
128
  * @param {LH.Artifacts} artifacts
127
129
  * @param {LH.Audit.Context} context
128
- * @return {Promise<{wastedMs: number, results: Array<{url: string, totalBytes: number, wastedMs: number}>}>}
130
+ * @return {Promise<{fcpWastedMs: number, lcpWastedMs: number, results: Array<{url: string, totalBytes: number, wastedMs: number}>}>}
129
131
  */
130
132
  static async computeResults(artifacts, context) {
131
133
  const gatherContext = artifacts.GatherContext;
@@ -179,10 +181,10 @@ class RenderBlockingResources extends Audit {
179
181
  }
180
182
 
181
183
  if (!results.length) {
182
- return {results, wastedMs: 0};
184
+ return {results, fcpWastedMs: 0, lcpWastedMs: 0};
183
185
  }
184
186
 
185
- const wastedMs = RenderBlockingResources.estimateSavingsWithGraphs(
187
+ const fcpWastedMs = RenderBlockingResources.estimateSavingsWithGraphs(
186
188
  simulator,
187
189
  fcpSimulation.optimisticGraph,
188
190
  deferredNodeIds,
@@ -190,7 +192,10 @@ class RenderBlockingResources extends Audit {
190
192
  artifacts.Stacks
191
193
  );
192
194
 
193
- return {results, wastedMs};
195
+ const lcpRecord = await LCPImageRecord.request(metricComputationData, context);
196
+
197
+ // In most cases if the LCP is an image, render blocking resources don't affect LCP. For these cases we should reduce its impact.
198
+ return {results, fcpWastedMs, lcpWastedMs: lcpRecord ? 0 : fcpWastedMs};
194
199
  }
195
200
 
196
201
  /**
@@ -276,11 +281,12 @@ class RenderBlockingResources extends Audit {
276
281
  * @return {Promise<LH.Audit.Product>}
277
282
  */
278
283
  static async audit(artifacts, context) {
279
- const {results, wastedMs} = await RenderBlockingResources.computeResults(artifacts, context);
284
+ const {results, fcpWastedMs, lcpWastedMs} =
285
+ await RenderBlockingResources.computeResults(artifacts, context);
280
286
 
281
287
  let displayValue;
282
288
  if (results.length > 0) {
283
- displayValue = str_(i18n.UIStrings.displayValueMsSavings, {wastedMs});
289
+ displayValue = str_(i18n.UIStrings.displayValueMsSavings, {wastedMs: fcpWastedMs});
284
290
  }
285
291
 
286
292
  /** @type {LH.Audit.Details.Opportunity['headings']} */
@@ -291,15 +297,15 @@ class RenderBlockingResources extends Audit {
291
297
  ];
292
298
 
293
299
  const details = Audit.makeOpportunityDetails(headings, results,
294
- {overallSavingsMs: wastedMs});
300
+ {overallSavingsMs: fcpWastedMs});
295
301
 
296
302
  return {
297
303
  displayValue,
298
304
  score: results.length ? 0 : 1,
299
- numericValue: wastedMs,
305
+ numericValue: fcpWastedMs,
300
306
  numericUnit: 'millisecond',
301
307
  details,
302
- metricSavings: {FCP: wastedMs, LCP: wastedMs},
308
+ metricSavings: {FCP: fcpWastedMs, LCP: lcpWastedMs},
303
309
  };
304
310
  }
305
311
  }
@@ -303,7 +303,7 @@ async function navigationGather(page, requestor, options = {}) {
303
303
  page,
304
304
  resolvedConfig,
305
305
  requestor: normalizedRequestor,
306
- computedCache: new Map(),
306
+ computedCache,
307
307
  };
308
308
  const {baseArtifacts} = await _setup(context);
309
309
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "lighthouse",
3
3
  "type": "module",
4
- "version": "11.4.0-dev.20231219",
4
+ "version": "11.4.0-dev.20231221",
5
5
  "description": "Automated auditing, performance metrics, and best practices for the web.",
6
6
  "main": "./core/index.js",
7
7
  "bin": {