lighthouse 12.8.2 → 13.0.0-dev.20251009
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.
- package/cli/cli-flags.js +1 -1
- package/cli/test/smokehouse/config/exclusions.js +0 -2
- package/cli/test/smokehouse/version-check.d.ts +1 -1
- package/core/audits/accessibility/accesskeys.js +3 -3
- package/core/audits/accessibility/aria-allowed-attr.js +3 -3
- package/core/audits/accessibility/aria-allowed-role.js +2 -1
- package/core/audits/accessibility/aria-command-name.js +1 -1
- package/core/audits/accessibility/aria-conditional-attr.js +1 -1
- package/core/audits/accessibility/aria-deprecated-role.js +1 -1
- package/core/audits/accessibility/aria-dialog-name.js +1 -1
- package/core/audits/accessibility/aria-hidden-body.js +3 -3
- package/core/audits/accessibility/aria-hidden-focus.js +3 -3
- package/core/audits/accessibility/aria-input-field-name.js +3 -3
- package/core/audits/accessibility/aria-meter-name.js +1 -1
- package/core/audits/accessibility/aria-progressbar-name.js +1 -1
- package/core/audits/accessibility/aria-prohibited-attr.js +1 -1
- package/core/audits/accessibility/aria-required-attr.js +3 -3
- package/core/audits/accessibility/aria-required-children.js +3 -3
- package/core/audits/accessibility/aria-required-parent.js +3 -3
- package/core/audits/accessibility/aria-roles.js +3 -3
- package/core/audits/accessibility/aria-text.js +3 -3
- package/core/audits/accessibility/aria-toggle-field-name.js +3 -3
- package/core/audits/accessibility/aria-tooltip-name.js +1 -1
- package/core/audits/accessibility/aria-treeitem-name.js +1 -1
- package/core/audits/accessibility/aria-valid-attr-value.js +3 -3
- package/core/audits/accessibility/aria-valid-attr.js +3 -3
- package/core/audits/accessibility/button-name.js +3 -3
- package/core/audits/accessibility/bypass.js +3 -3
- package/core/audits/accessibility/color-contrast.js +3 -3
- package/core/audits/accessibility/definition-list.js +3 -3
- package/core/audits/accessibility/dlitem.js +3 -3
- package/core/audits/accessibility/document-title.js +3 -3
- package/core/audits/accessibility/duplicate-id-aria.js +3 -3
- package/core/audits/accessibility/empty-heading.js +3 -3
- package/core/audits/accessibility/form-field-multiple-labels.js +3 -3
- package/core/audits/accessibility/frame-title.js +3 -3
- package/core/audits/accessibility/heading-order.js +3 -3
- package/core/audits/accessibility/html-has-lang.js +3 -3
- package/core/audits/accessibility/html-lang-valid.js +3 -3
- package/core/audits/accessibility/html-xml-lang-mismatch.js +3 -3
- package/core/audits/accessibility/identical-links-same-purpose.js +3 -3
- package/core/audits/accessibility/image-alt.js +3 -3
- package/core/audits/accessibility/image-redundant-alt.js +4 -3
- package/core/audits/accessibility/input-button-name.js +3 -3
- package/core/audits/accessibility/input-image-alt.js +3 -3
- package/core/audits/accessibility/label-content-name-mismatch.js +3 -3
- package/core/audits/accessibility/label.js +3 -3
- package/core/audits/accessibility/landmark-one-main.js +3 -4
- package/core/audits/accessibility/link-in-text-block.js +3 -3
- package/core/audits/accessibility/link-name.js +3 -3
- package/core/audits/accessibility/list.js +3 -3
- package/core/audits/accessibility/listitem.js +3 -3
- package/core/audits/accessibility/meta-refresh.js +3 -3
- package/core/audits/accessibility/meta-viewport.js +3 -3
- package/core/audits/accessibility/object-alt.js +3 -3
- package/core/audits/accessibility/select-name.js +3 -3
- package/core/audits/accessibility/skip-link.js +3 -3
- package/core/audits/accessibility/tabindex.js +3 -3
- package/core/audits/accessibility/table-duplicate-name.js +4 -3
- package/core/audits/accessibility/table-fake-caption.js +3 -3
- package/core/audits/accessibility/target-size.js +3 -3
- package/core/audits/accessibility/td-has-header.js +3 -3
- package/core/audits/accessibility/td-headers-attr.js +3 -3
- package/core/audits/accessibility/th-has-data-cells.js +3 -3
- package/core/audits/accessibility/valid-lang.js +3 -3
- package/core/audits/accessibility/video-caption.js +3 -3
- package/core/audits/audit.d.ts +0 -4
- package/core/audits/audit.js +2 -13
- package/core/audits/insights/cls-culprits-insight.js +1 -1
- package/core/audits/insights/dom-size-insight.js +11 -7
- package/core/audits/insights/font-display-insight.js +3 -1
- package/core/audits/insights/image-delivery-insight.js +4 -1
- package/core/audits/insights/insight-audit.d.ts +6 -4
- package/core/audits/insights/insight-audit.js +27 -8
- package/core/audits/insights/third-parties-insight.js +1 -1
- package/core/audits/layout-shifts.js +1 -1
- package/core/audits/predictive-perf.js +2 -2
- package/core/audits/seo/crawlable-anchors.js +2 -3
- package/core/audits/seo/manual/structured-data.js +1 -1
- package/core/audits/server-response-time.d.ts +0 -5
- package/core/audits/server-response-time.js +12 -26
- package/core/computed/metrics/cumulative-layout-shift.js +2 -2
- package/core/computed/metrics/lantern-metric.js +3 -3
- package/core/computed/metrics/lcp-breakdown.d.ts +10 -5
- package/core/computed/metrics/lcp-breakdown.js +50 -22
- package/core/computed/metrics/time-to-first-byte.js +33 -10
- package/core/computed/metrics/timing-summary.js +3 -2
- package/core/computed/page-dependency-graph.js +1 -1
- package/core/computed/trace-engine-result.js +2 -2
- package/core/config/default-config.js +110 -152
- package/core/config/experimental-config.js +1 -32
- package/core/config/filters.js +6 -9
- package/core/config/lr-desktop-config.js +0 -1
- package/core/config/lr-mobile-config.js +0 -1
- package/core/gather/driver/target-manager.d.ts +1 -1
- package/core/gather/driver.d.ts +1 -1
- package/core/gather/gatherers/anchor-elements.js +8 -24
- package/core/gather/gatherers/image-elements.js +32 -6
- package/core/gather/gatherers/inspector-issues.js +1 -28
- package/core/gather/gatherers/trace-elements.d.ts +2 -11
- package/core/gather/gatherers/trace-elements.js +9 -39
- package/core/gather/navigation-runner.js +0 -3
- package/core/gather/session.d.ts +1 -1
- package/core/lib/asset-saver.d.ts +2 -2
- package/core/lib/asset-saver.js +33 -43
- package/core/lib/bf-cache-strings.js +10 -9
- package/core/lib/deprecations-strings.js +5 -5
- package/core/lib/emulation.d.ts +10 -0
- package/core/lib/emulation.js +21 -6
- package/core/lib/legacy-javascript/legacy-javascript.js +4 -11
- package/core/lib/network-request.d.ts +0 -7
- package/core/lib/network-request.js +0 -16
- package/core/lib/proto-preprocessor.js +10 -25
- package/core/runner.js +1 -8
- package/core/scoring.js +1 -1
- package/dist/report/bundle.esm.js +10 -49
- package/dist/report/flow.js +12 -51
- package/dist/report/standalone.js +11 -50
- package/flow-report/src/i18n/i18n.d.ts +4 -6
- package/package.json +16 -19
- package/readme.md +2 -2
- package/report/assets/styles.css +0 -39
- package/report/renderer/api.js +0 -1
- package/report/renderer/category-renderer.js +6 -0
- package/report/renderer/components.js +1 -1
- package/report/renderer/details-renderer.d.ts +1 -2
- package/report/renderer/details-renderer.js +0 -1
- package/report/renderer/dom.d.ts +0 -13
- package/report/renderer/dom.js +0 -38
- package/report/renderer/performance-category-renderer.d.ts +0 -26
- package/report/renderer/performance-category-renderer.js +10 -142
- package/report/renderer/report-ui-features.d.ts +0 -1
- package/report/renderer/report-ui-features.js +2 -13
- package/report/renderer/report-utils.d.ts +2 -3
- package/report/renderer/report-utils.js +4 -6
- package/report/types/report-renderer.d.ts +0 -6
- package/shared/localization/locales/ar-XB.json +107 -455
- package/shared/localization/locales/ar.json +107 -455
- package/shared/localization/locales/bg.json +96 -444
- package/shared/localization/locales/ca.json +96 -444
- package/shared/localization/locales/cs.json +96 -444
- package/shared/localization/locales/da.json +96 -444
- package/shared/localization/locales/de.json +96 -444
- package/shared/localization/locales/el.json +96 -444
- package/shared/localization/locales/en-GB.json +96 -444
- package/shared/localization/locales/en-US.json +116 -467
- package/shared/localization/locales/en-XA.json +93 -441
- package/shared/localization/locales/en-XL.json +116 -467
- package/shared/localization/locales/es-419.json +96 -444
- package/shared/localization/locales/es.json +96 -444
- package/shared/localization/locales/fi.json +96 -444
- package/shared/localization/locales/fil.json +96 -444
- package/shared/localization/locales/fr.json +96 -444
- package/shared/localization/locales/he.json +118 -466
- package/shared/localization/locales/hi.json +96 -444
- package/shared/localization/locales/hr.json +100 -448
- package/shared/localization/locales/hu.json +96 -444
- package/shared/localization/locales/id.json +96 -444
- package/shared/localization/locales/it.json +96 -444
- package/shared/localization/locales/ja.json +96 -444
- package/shared/localization/locales/ko.json +97 -445
- package/shared/localization/locales/lt.json +96 -444
- package/shared/localization/locales/lv.json +97 -445
- package/shared/localization/locales/nl.json +96 -444
- package/shared/localization/locales/no.json +96 -444
- package/shared/localization/locales/pl.json +96 -444
- package/shared/localization/locales/pt-PT.json +96 -444
- package/shared/localization/locales/pt.json +97 -445
- package/shared/localization/locales/ro.json +97 -445
- package/shared/localization/locales/ru.json +96 -444
- package/shared/localization/locales/sk.json +96 -444
- package/shared/localization/locales/sl.json +96 -444
- package/shared/localization/locales/sr-Latn.json +96 -444
- package/shared/localization/locales/sr.json +96 -444
- package/shared/localization/locales/sv.json +96 -444
- package/shared/localization/locales/ta.json +96 -444
- package/shared/localization/locales/te.json +97 -445
- package/shared/localization/locales/th.json +96 -444
- package/shared/localization/locales/tr.json +96 -444
- package/shared/localization/locales/uk.json +96 -444
- package/shared/localization/locales/vi.json +96 -444
- package/shared/localization/locales/zh-HK.json +96 -444
- package/shared/localization/locales/zh-TW.json +97 -445
- package/shared/localization/locales/zh.json +96 -444
- package/shared/localization/locales.d.ts +2 -0
- package/shared/localization/locales.js +130 -139
- package/shared/tsconfig.json +2 -0
- package/tsconfig-base.json +2 -2
- package/tsconfig.json +1 -4
- package/types/artifacts.d.ts +6 -81
- package/types/audit.d.ts +1 -1
- package/types/lhr/settings.d.ts +1 -1
- package/core/audits/byte-efficiency/duplicated-javascript.d.ts +0 -45
- package/core/audits/byte-efficiency/duplicated-javascript.js +0 -223
- package/core/audits/byte-efficiency/efficient-animated-content.d.ts +0 -22
- package/core/audits/byte-efficiency/efficient-animated-content.js +0 -93
- package/core/audits/byte-efficiency/legacy-javascript.d.ts +0 -28
- package/core/audits/byte-efficiency/legacy-javascript.js +0 -144
- package/core/audits/byte-efficiency/modern-image-formats.d.ts +0 -38
- package/core/audits/byte-efficiency/modern-image-formats.js +0 -187
- package/core/audits/byte-efficiency/offscreen-images.d.ts +0 -63
- package/core/audits/byte-efficiency/offscreen-images.js +0 -240
- package/core/audits/byte-efficiency/render-blocking-resources.d.ts +0 -53
- package/core/audits/byte-efficiency/render-blocking-resources.js +0 -312
- package/core/audits/byte-efficiency/uses-long-cache-ttl.d.ts +0 -59
- package/core/audits/byte-efficiency/uses-long-cache-ttl.js +0 -293
- package/core/audits/byte-efficiency/uses-optimized-images.d.ts +0 -33
- package/core/audits/byte-efficiency/uses-optimized-images.js +0 -146
- package/core/audits/byte-efficiency/uses-responsive-images-snapshot.d.ts +0 -16
- package/core/audits/byte-efficiency/uses-responsive-images-snapshot.js +0 -106
- package/core/audits/byte-efficiency/uses-responsive-images.d.ts +0 -44
- package/core/audits/byte-efficiency/uses-responsive-images.js +0 -202
- package/core/audits/byte-efficiency/uses-text-compression.d.ts +0 -14
- package/core/audits/byte-efficiency/uses-text-compression.js +0 -108
- package/core/audits/critical-request-chains.d.ts +0 -44
- package/core/audits/critical-request-chains.js +0 -221
- package/core/audits/dobetterweb/dom-size.d.ts +0 -32
- package/core/audits/dobetterweb/dom-size.js +0 -182
- package/core/audits/dobetterweb/no-document-write.d.ts +0 -16
- package/core/audits/dobetterweb/no-document-write.js +0 -86
- package/core/audits/dobetterweb/uses-http2.d.ts +0 -72
- package/core/audits/dobetterweb/uses-http2.js +0 -276
- package/core/audits/dobetterweb/uses-passive-event-listeners.d.ts +0 -16
- package/core/audits/dobetterweb/uses-passive-event-listeners.js +0 -69
- package/core/audits/font-display.d.ts +0 -32
- package/core/audits/font-display.js +0 -195
- package/core/audits/largest-contentful-paint-element.d.ts +0 -34
- package/core/audits/largest-contentful-paint-element.js +0 -181
- package/core/audits/lcp-lazy-loaded.d.ts +0 -22
- package/core/audits/lcp-lazy-loaded.js +0 -115
- package/core/audits/metrics/first-meaningful-paint.d.ts +0 -12
- package/core/audits/metrics/first-meaningful-paint.js +0 -47
- package/core/audits/preload-fonts.d.ts +0 -25
- package/core/audits/preload-fonts.js +0 -97
- package/core/audits/prioritize-lcp-image.d.ts +0 -74
- package/core/audits/prioritize-lcp-image.js +0 -297
- package/core/audits/seo/font-size.d.ts +0 -24
- package/core/audits/seo/font-size.js +0 -344
- package/core/audits/third-party-facades.d.ts +0 -41
- package/core/audits/third-party-facades.js +0 -234
- package/core/audits/third-party-summary.d.ts +0 -78
- package/core/audits/third-party-summary.js +0 -236
- package/core/audits/uses-rel-preconnect.d.ts +0 -37
- package/core/audits/uses-rel-preconnect.js +0 -286
- package/core/audits/uses-rel-preload.d.ts +0 -57
- package/core/audits/uses-rel-preload.js +0 -263
- package/core/audits/viewport.d.ts +0 -17
- package/core/audits/viewport.js +0 -87
- package/core/audits/work-during-interaction.d.ts +0 -81
- package/core/audits/work-during-interaction.js +0 -287
- package/core/computed/critical-request-chains.d.ts +0 -42
- package/core/computed/critical-request-chains.js +0 -143
- package/core/computed/viewport-meta.d.ts +0 -37
- package/core/computed/viewport-meta.js +0 -71
- package/core/gather/gatherers/cache-contents.d.ts +0 -11
- package/core/gather/gatherers/cache-contents.js +0 -56
- package/core/gather/gatherers/devtools-log-compat.d.ts +0 -13
- package/core/gather/gatherers/devtools-log-compat.js +0 -35
- package/core/gather/gatherers/dobetterweb/domstats.d.ts +0 -10
- package/core/gather/gatherers/dobetterweb/domstats.js +0 -102
- package/core/gather/gatherers/dobetterweb/optimized-images.d.ts +0 -48
- package/core/gather/gatherers/dobetterweb/optimized-images.js +0 -169
- package/core/gather/gatherers/dobetterweb/response-compression.d.ts +0 -23
- package/core/gather/gatherers/dobetterweb/response-compression.js +0 -136
- package/core/gather/gatherers/seo/font-size.d.ts +0 -131
- package/core/gather/gatherers/seo/font-size.js +0 -347
- package/core/gather/gatherers/trace-compat.d.ts +0 -13
- package/core/gather/gatherers/trace-compat.js +0 -35
- package/types/internal/metaviewport-parser.d.ts +0 -13
- package/types/internal/parse-cache-control.d.ts +0 -20
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export default ThirdPartyFacades;
|
|
2
|
-
export type ThirdPartyEntity = import("third-party-web").IEntity;
|
|
3
|
-
export type ThirdPartyProduct = import("third-party-web").IProduct;
|
|
4
|
-
export type ThirdPartyFacade = import("third-party-web").IFacade;
|
|
5
|
-
export type FacadableProduct = {
|
|
6
|
-
product: ThirdPartyProduct;
|
|
7
|
-
entity: ThirdPartyEntity;
|
|
8
|
-
};
|
|
9
|
-
declare class ThirdPartyFacades extends Audit {
|
|
10
|
-
/**
|
|
11
|
-
* Sort items by transfer size and combine small items into a single row.
|
|
12
|
-
* Items will be mutated in place to a maximum of 6 rows.
|
|
13
|
-
* @param {import('./third-party-summary.js').URLSummary[]} items
|
|
14
|
-
*/
|
|
15
|
-
static condenseItems(items: import("./third-party-summary.js").URLSummary[]): void;
|
|
16
|
-
/**
|
|
17
|
-
* @param {Map<string, import('./third-party-summary.js').Summary>} byURL
|
|
18
|
-
* @param {LH.Artifacts.EntityClassification} classifiedEntities
|
|
19
|
-
* @return {FacadableProduct[]}
|
|
20
|
-
*/
|
|
21
|
-
static getProductsWithFacade(byURL: Map<string, import("./third-party-summary.js").Summary>, classifiedEntities: LH.Artifacts.EntityClassification): FacadableProduct[];
|
|
22
|
-
/**
|
|
23
|
-
* @param {LH.Artifacts} artifacts
|
|
24
|
-
* @param {LH.Audit.Context} context
|
|
25
|
-
* @return {Promise<LH.Audit.Product>}
|
|
26
|
-
*/
|
|
27
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
28
|
-
}
|
|
29
|
-
export namespace UIStrings {
|
|
30
|
-
let title: string;
|
|
31
|
-
let failureTitle: string;
|
|
32
|
-
let description: string;
|
|
33
|
-
let displayValue: string;
|
|
34
|
-
let columnProduct: string;
|
|
35
|
-
let categoryVideo: string;
|
|
36
|
-
let categoryCustomerSuccess: string;
|
|
37
|
-
let categoryMarketing: string;
|
|
38
|
-
let categorySocial: string;
|
|
39
|
-
}
|
|
40
|
-
import { Audit } from './audit.js';
|
|
41
|
-
//# sourceMappingURL=third-party-facades.d.ts.map
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2020 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview Audit which identifies third-party code on the page which can be lazy loaded.
|
|
9
|
-
* The audit will recommend a facade alternative which is used to imitate the third-party resource until it is needed.
|
|
10
|
-
*
|
|
11
|
-
* Entity: Set of domains which are used by a company or product area to deliver third-party resources
|
|
12
|
-
* Product: Specific piece of software belonging to an entity. Entities can have multiple products.
|
|
13
|
-
* Facade: Placeholder for a product which looks likes the actual product and replaces itself with that product when the user needs it.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
/** @typedef {import("third-party-web").IEntity} ThirdPartyEntity */
|
|
17
|
-
/** @typedef {import("third-party-web").IProduct} ThirdPartyProduct*/
|
|
18
|
-
/** @typedef {import("third-party-web").IFacade} ThirdPartyFacade*/
|
|
19
|
-
|
|
20
|
-
/** @typedef {{product: ThirdPartyProduct, entity: ThirdPartyEntity}} FacadableProduct */
|
|
21
|
-
|
|
22
|
-
import {Audit} from './audit.js';
|
|
23
|
-
import * as i18n from '../lib/i18n/i18n.js';
|
|
24
|
-
import {EntityClassification} from '../computed/entity-classification.js';
|
|
25
|
-
import thirdPartyWeb from '../lib/third-party-web.js';
|
|
26
|
-
import {NetworkRecords} from '../computed/network-records.js';
|
|
27
|
-
import ThirdPartySummary from './third-party-summary.js';
|
|
28
|
-
import {TBTImpactTasks} from '../computed/tbt-impact-tasks.js';
|
|
29
|
-
|
|
30
|
-
const UIStrings = {
|
|
31
|
-
/** Title of a diagnostic audit that provides details about the third-party code on a web page that can be lazy loaded with a facade alternative. This descriptive title is shown to users when no resources have facade alternatives available. A facade is a lightweight component which looks like the desired resource. Lazy loading means resources are deferred until they are needed. Third-party code refers to resources that are not within the control of the site owner. */
|
|
32
|
-
title: 'Lazy load third-party resources with facades',
|
|
33
|
-
/** Title of a diagnostic audit that provides details about the third-party code on a web page that can be lazy loaded with a facade alternative. This descriptive title is shown to users when one or more third-party resources have available facade alternatives. A facade is a lightweight component which looks like the desired resource. Lazy loading means resources are deferred until they are needed. Third-party code refers to resources that are not within the control of the site owner. */
|
|
34
|
-
failureTitle: 'Some third-party resources can be lazy loaded with a facade',
|
|
35
|
-
/** Description of a Lighthouse audit that identifies the third-party code on the page that can be lazy loaded with a facade alternative. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. A facade is a lightweight component which looks like the desired resource. Lazy loading means resources are deferred until they are needed. Third-party code refers to resources that are not within the control of the site owner. */
|
|
36
|
-
description: 'Some third-party embeds can be lazy loaded. ' +
|
|
37
|
-
'Consider replacing them with a facade until they are required. ' +
|
|
38
|
-
'[Learn how to defer third-parties with a facade](https://developer.chrome.com/docs/lighthouse/performance/third-party-facades/).',
|
|
39
|
-
/** Summary text for the result of a Lighthouse audit that identifies the third-party code on a web page that can be lazy loaded with a facade alternative. This text summarizes the number of lazy loading facades that can be used on the page. A facade is a lightweight component which looks like the desired resource. */
|
|
40
|
-
displayValue: `{itemCount, plural,
|
|
41
|
-
=1 {# facade alternative available}
|
|
42
|
-
other {# facade alternatives available}
|
|
43
|
-
}`,
|
|
44
|
-
/** Label for a table column that displays the name of the product that a URL is used for. The products in the column will be pieces of software used on the page, like the "YouTube Embedded Player" or the "Drift Live Chat" box. */
|
|
45
|
-
columnProduct: 'Product',
|
|
46
|
-
/**
|
|
47
|
-
* @description Template for a table entry that gives the name of a product which we categorize as video related.
|
|
48
|
-
* @example {YouTube Embedded Player} productName
|
|
49
|
-
*/
|
|
50
|
-
categoryVideo: '{productName} (Video)',
|
|
51
|
-
/**
|
|
52
|
-
* @description Template for a table entry that gives the name of a product which we categorize as customer success related. Customer success means the product supports customers by offering chat and contact solutions.
|
|
53
|
-
* @example {Intercom Widget} productName
|
|
54
|
-
*/
|
|
55
|
-
categoryCustomerSuccess: '{productName} (Customer Success)',
|
|
56
|
-
/**
|
|
57
|
-
* @description Template for a table entry that gives the name of a product which we categorize as marketing related.
|
|
58
|
-
* @example {Drift Live Chat} productName
|
|
59
|
-
*/
|
|
60
|
-
categoryMarketing: '{productName} (Marketing)',
|
|
61
|
-
/**
|
|
62
|
-
* @description Template for a table entry that gives the name of a product which we categorize as social related.
|
|
63
|
-
* @example {Facebook Messenger Customer Chat} productName
|
|
64
|
-
*/
|
|
65
|
-
categorySocial: '{productName} (Social)',
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
69
|
-
|
|
70
|
-
/** @type {Record<string, string>} */
|
|
71
|
-
const CATEGORY_UI_MAP = {
|
|
72
|
-
'video': UIStrings.categoryVideo,
|
|
73
|
-
'customer-success': UIStrings.categoryCustomerSuccess,
|
|
74
|
-
'marketing': UIStrings.categoryMarketing,
|
|
75
|
-
'social': UIStrings.categorySocial,
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
class ThirdPartyFacades extends Audit {
|
|
79
|
-
/**
|
|
80
|
-
* @return {LH.Audit.Meta}
|
|
81
|
-
*/
|
|
82
|
-
static get meta() {
|
|
83
|
-
return {
|
|
84
|
-
id: 'third-party-facades',
|
|
85
|
-
title: str_(UIStrings.title),
|
|
86
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
87
|
-
description: str_(UIStrings.description),
|
|
88
|
-
supportedModes: ['navigation'],
|
|
89
|
-
guidanceLevel: 3,
|
|
90
|
-
requiredArtifacts: ['Trace', 'DevtoolsLog', 'URL', 'GatherContext', 'SourceMaps'],
|
|
91
|
-
scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Sort items by transfer size and combine small items into a single row.
|
|
97
|
-
* Items will be mutated in place to a maximum of 6 rows.
|
|
98
|
-
* @param {import('./third-party-summary.js').URLSummary[]} items
|
|
99
|
-
*/
|
|
100
|
-
static condenseItems(items) {
|
|
101
|
-
items.sort((a, b) => b.transferSize - a.transferSize);
|
|
102
|
-
|
|
103
|
-
// Items <1KB are condensed. If all items are <1KB, condense all but the largest.
|
|
104
|
-
let splitIndex = items.findIndex((item) => item.transferSize < 1000) || 1;
|
|
105
|
-
// Show details for top 5 items.
|
|
106
|
-
if (splitIndex === -1 || splitIndex > 5) splitIndex = 5;
|
|
107
|
-
// If there is only 1 item to condense, leave it as is.
|
|
108
|
-
if (splitIndex >= items.length - 1) return;
|
|
109
|
-
|
|
110
|
-
const remainder = items.splice(splitIndex);
|
|
111
|
-
const finalItem = remainder.reduce((result, item) => {
|
|
112
|
-
result.transferSize += item.transferSize;
|
|
113
|
-
result.blockingTime += item.blockingTime;
|
|
114
|
-
return result;
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// If condensed row is still <1KB, don't show it.
|
|
118
|
-
if (finalItem.transferSize < 1000) return;
|
|
119
|
-
|
|
120
|
-
finalItem.url = str_(i18n.UIStrings.otherResourcesLabel);
|
|
121
|
-
items.push(finalItem);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* @param {Map<string, import('./third-party-summary.js').Summary>} byURL
|
|
126
|
-
* @param {LH.Artifacts.EntityClassification} classifiedEntities
|
|
127
|
-
* @return {FacadableProduct[]}
|
|
128
|
-
*/
|
|
129
|
-
static getProductsWithFacade(byURL, classifiedEntities) {
|
|
130
|
-
/** @type {Map<string, FacadableProduct>} */
|
|
131
|
-
const facadableProductMap = new Map();
|
|
132
|
-
for (const url of byURL.keys()) {
|
|
133
|
-
const entity = classifiedEntities.entityByUrl.get(url);
|
|
134
|
-
if (!entity || classifiedEntities.isFirstParty(url)) continue;
|
|
135
|
-
|
|
136
|
-
const product = thirdPartyWeb.getProduct(url);
|
|
137
|
-
if (!product || !product.facades || !product.facades.length) continue;
|
|
138
|
-
|
|
139
|
-
if (facadableProductMap.has(product.name)) continue;
|
|
140
|
-
facadableProductMap.set(product.name, {product, entity});
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
return Array.from(facadableProductMap.values());
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @param {LH.Artifacts} artifacts
|
|
148
|
-
* @param {LH.Audit.Context} context
|
|
149
|
-
* @return {Promise<LH.Audit.Product>}
|
|
150
|
-
*/
|
|
151
|
-
static async audit(artifacts, context) {
|
|
152
|
-
const settings = context.settings;
|
|
153
|
-
const devtoolsLog = artifacts.DevtoolsLog;
|
|
154
|
-
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
155
|
-
const classifiedEntities = await EntityClassification.request(
|
|
156
|
-
{URL: artifacts.URL, devtoolsLog}, context);
|
|
157
|
-
|
|
158
|
-
const metricComputationData = Audit.makeMetricComputationDataInput(artifacts, context);
|
|
159
|
-
const tbtImpactTasks = await TBTImpactTasks.request(metricComputationData, context);
|
|
160
|
-
|
|
161
|
-
const multiplier = settings.throttlingMethod === 'simulate' ?
|
|
162
|
-
settings.throttling.cpuSlowdownMultiplier : 1;
|
|
163
|
-
const summaries = ThirdPartySummary.getSummaries(networkRecords, tbtImpactTasks, multiplier,
|
|
164
|
-
classifiedEntities);
|
|
165
|
-
const facadableProducts =
|
|
166
|
-
ThirdPartyFacades.getProductsWithFacade(summaries.byURL, classifiedEntities);
|
|
167
|
-
|
|
168
|
-
let tbtImpact = 0;
|
|
169
|
-
|
|
170
|
-
/** @type {LH.Audit.Details.TableItem[]} */
|
|
171
|
-
const results = [];
|
|
172
|
-
for (const {product, entity} of facadableProducts) {
|
|
173
|
-
const categoryTemplate = CATEGORY_UI_MAP[product.categories[0]];
|
|
174
|
-
|
|
175
|
-
let productWithCategory;
|
|
176
|
-
if (categoryTemplate) {
|
|
177
|
-
// Display product name with category next to it in the same column.
|
|
178
|
-
productWithCategory = str_(categoryTemplate, {productName: product.name});
|
|
179
|
-
} else {
|
|
180
|
-
// Just display product name if no category is found.
|
|
181
|
-
productWithCategory = product.name;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const urls = summaries.urls.get(entity);
|
|
185
|
-
const entitySummary = summaries.byEntity.get(entity);
|
|
186
|
-
if (!urls || !entitySummary) continue;
|
|
187
|
-
|
|
188
|
-
tbtImpact += entitySummary.tbtImpact;
|
|
189
|
-
|
|
190
|
-
const items = Array.from(urls).map((url) => {
|
|
191
|
-
const urlStats = summaries.byURL.get(url);
|
|
192
|
-
return /** @type {import('./third-party-summary.js').URLSummary} */ ({url, ...urlStats});
|
|
193
|
-
});
|
|
194
|
-
this.condenseItems(items);
|
|
195
|
-
results.push({
|
|
196
|
-
product: productWithCategory,
|
|
197
|
-
transferSize: entitySummary.transferSize,
|
|
198
|
-
blockingTime: entitySummary.blockingTime,
|
|
199
|
-
subItems: {type: 'subitems', items},
|
|
200
|
-
// Add entity manually since facades don't have a single `url`.
|
|
201
|
-
entity: entity.name,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (!results.length) {
|
|
206
|
-
return {
|
|
207
|
-
score: 1,
|
|
208
|
-
notApplicable: true,
|
|
209
|
-
metricSavings: {TBT: 0},
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/** @type {LH.Audit.Details.Table['headings']} */
|
|
214
|
-
const headings = [
|
|
215
|
-
/* eslint-disable max-len */
|
|
216
|
-
{key: 'product', valueType: 'text', subItemsHeading: {key: 'url', valueType: 'url'}, label: str_(UIStrings.columnProduct)},
|
|
217
|
-
{key: 'transferSize', valueType: 'bytes', subItemsHeading: {key: 'transferSize'}, granularity: 1, label: str_(i18n.UIStrings.columnTransferSize)},
|
|
218
|
-
{key: 'blockingTime', valueType: 'ms', subItemsHeading: {key: 'blockingTime'}, granularity: 1, label: str_(i18n.UIStrings.columnBlockingTime)},
|
|
219
|
-
/* eslint-enable max-len */
|
|
220
|
-
];
|
|
221
|
-
|
|
222
|
-
return {
|
|
223
|
-
score: 0,
|
|
224
|
-
displayValue: str_(UIStrings.displayValue, {
|
|
225
|
-
itemCount: results.length,
|
|
226
|
-
}),
|
|
227
|
-
details: Audit.makeTableDetails(headings, results),
|
|
228
|
-
metricSavings: {TBT: Math.round(tbtImpact)},
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
export default ThirdPartyFacades;
|
|
234
|
-
export {UIStrings};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export default ThirdPartySummary;
|
|
2
|
-
export type Summary = {
|
|
3
|
-
mainThreadTime: number;
|
|
4
|
-
transferSize: number;
|
|
5
|
-
blockingTime: number;
|
|
6
|
-
tbtImpact: number;
|
|
7
|
-
};
|
|
8
|
-
export type URLSummary = {
|
|
9
|
-
transferSize: number;
|
|
10
|
-
blockingTime: number;
|
|
11
|
-
tbtImpact: number;
|
|
12
|
-
url: string | LH.IcuMessage;
|
|
13
|
-
};
|
|
14
|
-
export type SummaryMaps = {
|
|
15
|
-
/**
|
|
16
|
-
* Map of impact summaries for each entity.
|
|
17
|
-
*/
|
|
18
|
-
byEntity: Map<LH.Artifacts.Entity, Summary>;
|
|
19
|
-
/**
|
|
20
|
-
* Map of impact summaries for each URL.
|
|
21
|
-
*/
|
|
22
|
-
byURL: Map<string, Summary>;
|
|
23
|
-
/**
|
|
24
|
-
* Map of URLs under each entity.
|
|
25
|
-
*/
|
|
26
|
-
urls: Map<LH.Artifacts.Entity, string[]>;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* @typedef Summary
|
|
30
|
-
* @property {number} mainThreadTime
|
|
31
|
-
* @property {number} transferSize
|
|
32
|
-
* @property {number} blockingTime
|
|
33
|
-
* @property {number} tbtImpact
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* @typedef URLSummary
|
|
37
|
-
* @property {number} transferSize
|
|
38
|
-
* @property {number} blockingTime
|
|
39
|
-
* @property {number} tbtImpact
|
|
40
|
-
* @property {string | LH.IcuMessage} url
|
|
41
|
-
*/
|
|
42
|
-
/** @typedef SummaryMaps
|
|
43
|
-
* @property {Map<LH.Artifacts.Entity, Summary>} byEntity Map of impact summaries for each entity.
|
|
44
|
-
* @property {Map<string, Summary>} byURL Map of impact summaries for each URL.
|
|
45
|
-
* @property {Map<LH.Artifacts.Entity, string[]>} urls Map of URLs under each entity.
|
|
46
|
-
*/
|
|
47
|
-
declare class ThirdPartySummary extends Audit {
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
51
|
-
* @param {Array<LH.Artifacts.TBTImpactTask>} tbtImpactTasks
|
|
52
|
-
* @param {number} cpuMultiplier
|
|
53
|
-
* @param {LH.Artifacts.EntityClassification} entityClassification
|
|
54
|
-
* @return {SummaryMaps}
|
|
55
|
-
*/
|
|
56
|
-
static getSummaries(networkRecords: Array<LH.Artifacts.NetworkRequest>, tbtImpactTasks: Array<LH.Artifacts.TBTImpactTask>, cpuMultiplier: number, entityClassification: LH.Artifacts.EntityClassification): SummaryMaps;
|
|
57
|
-
/**
|
|
58
|
-
* @param {LH.Artifacts.Entity} entity
|
|
59
|
-
* @param {SummaryMaps} summaries
|
|
60
|
-
* @return {Array<URLSummary>}
|
|
61
|
-
*/
|
|
62
|
-
static makeSubItems(entity: LH.Artifacts.Entity, summaries: SummaryMaps): Array<URLSummary>;
|
|
63
|
-
/**
|
|
64
|
-
* @param {LH.Artifacts} artifacts
|
|
65
|
-
* @param {LH.Audit.Context} context
|
|
66
|
-
* @return {Promise<LH.Audit.Product>}
|
|
67
|
-
*/
|
|
68
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
69
|
-
}
|
|
70
|
-
export namespace UIStrings {
|
|
71
|
-
let title: string;
|
|
72
|
-
let failureTitle: string;
|
|
73
|
-
let description: string;
|
|
74
|
-
let columnThirdParty: string;
|
|
75
|
-
let displayValue: string;
|
|
76
|
-
}
|
|
77
|
-
import { Audit } from './audit.js';
|
|
78
|
-
//# sourceMappingURL=third-party-summary.d.ts.map
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2019 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {Audit} from './audit.js';
|
|
8
|
-
import {EntityClassification} from '../computed/entity-classification.js';
|
|
9
|
-
import * as i18n from '../lib/i18n/i18n.js';
|
|
10
|
-
import {NetworkRecords} from '../computed/network-records.js';
|
|
11
|
-
import {getJavaScriptURLs, getAttributableURLForTask} from '../lib/tracehouse/task-summary.js';
|
|
12
|
-
import {TBTImpactTasks} from '../computed/tbt-impact-tasks.js';
|
|
13
|
-
|
|
14
|
-
const UIStrings = {
|
|
15
|
-
/** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This descriptive title is shown to users when the amount is acceptable and no user action is required. */
|
|
16
|
-
title: 'Minimize third-party usage',
|
|
17
|
-
/** Title of a diagnostic audit that provides details about the code on a web page that the user doesn't control (referred to as "third-party code"). This imperative title is shown to users when there is a significant amount of page execution time caused by third-party code that should be reduced. */
|
|
18
|
-
failureTitle: 'Reduce the impact of third-party code',
|
|
19
|
-
/** Description of a Lighthouse audit that identifies the code on the page that the user doesn't control. This is displayed after a user expands the section to see more. No character length limits. The last sentence starting with 'Learn' becomes link text to additional documentation. */
|
|
20
|
-
description: 'Third-party code can significantly impact load performance. ' +
|
|
21
|
-
'Limit the number of redundant third-party providers and try to load third-party code after ' +
|
|
22
|
-
'your page has primarily finished loading. ' +
|
|
23
|
-
'[Learn how to minimize third-party impact](https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/loading-third-party-javascript/).',
|
|
24
|
-
/** Label for a table column that displays the name of a third-party provider that potentially links to their website. */
|
|
25
|
-
columnThirdParty: 'Third-Party',
|
|
26
|
-
/** Summary text for the result of a Lighthouse audit that identifies the code on a web page that the user doesn't control (referred to as "third-party code"). This text summarizes the number of distinct entities that were found on the page. */
|
|
27
|
-
displayValue: 'Third-party code blocked the main thread for ' +
|
|
28
|
-
`{timeInMs, number, milliseconds}\xa0ms`,
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
32
|
-
|
|
33
|
-
// A page passes when all third-party code blocks for less than 250 ms.
|
|
34
|
-
const PASS_THRESHOLD_IN_MS = 250;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @typedef Summary
|
|
38
|
-
* @property {number} mainThreadTime
|
|
39
|
-
* @property {number} transferSize
|
|
40
|
-
* @property {number} blockingTime
|
|
41
|
-
* @property {number} tbtImpact
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @typedef URLSummary
|
|
46
|
-
* @property {number} transferSize
|
|
47
|
-
* @property {number} blockingTime
|
|
48
|
-
* @property {number} tbtImpact
|
|
49
|
-
* @property {string | LH.IcuMessage} url
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/** @typedef SummaryMaps
|
|
53
|
-
* @property {Map<LH.Artifacts.Entity, Summary>} byEntity Map of impact summaries for each entity.
|
|
54
|
-
* @property {Map<string, Summary>} byURL Map of impact summaries for each URL.
|
|
55
|
-
* @property {Map<LH.Artifacts.Entity, string[]>} urls Map of URLs under each entity.
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
class ThirdPartySummary extends Audit {
|
|
59
|
-
/**
|
|
60
|
-
* @return {LH.Audit.Meta}
|
|
61
|
-
*/
|
|
62
|
-
static get meta() {
|
|
63
|
-
return {
|
|
64
|
-
id: 'third-party-summary',
|
|
65
|
-
title: str_(UIStrings.title),
|
|
66
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
67
|
-
description: str_(UIStrings.description),
|
|
68
|
-
guidanceLevel: 1,
|
|
69
|
-
scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
|
|
70
|
-
requiredArtifacts: ['Trace', 'DevtoolsLog', 'URL', 'GatherContext', 'SourceMaps'],
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
*
|
|
76
|
-
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
77
|
-
* @param {Array<LH.Artifacts.TBTImpactTask>} tbtImpactTasks
|
|
78
|
-
* @param {number} cpuMultiplier
|
|
79
|
-
* @param {LH.Artifacts.EntityClassification} entityClassification
|
|
80
|
-
* @return {SummaryMaps}
|
|
81
|
-
*/
|
|
82
|
-
static getSummaries(networkRecords, tbtImpactTasks, cpuMultiplier, entityClassification) {
|
|
83
|
-
/** @type {Map<string, Summary>} */
|
|
84
|
-
const byURL = new Map();
|
|
85
|
-
/** @type {Map<LH.Artifacts.Entity, Summary>} */
|
|
86
|
-
const byEntity = new Map();
|
|
87
|
-
const defaultSummary = {mainThreadTime: 0, blockingTime: 0, transferSize: 0, tbtImpact: 0};
|
|
88
|
-
|
|
89
|
-
for (const request of networkRecords) {
|
|
90
|
-
const urlSummary = byURL.get(request.url) || {...defaultSummary};
|
|
91
|
-
urlSummary.transferSize += request.transferSize;
|
|
92
|
-
byURL.set(request.url, urlSummary);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const jsURLs = getJavaScriptURLs(networkRecords);
|
|
96
|
-
|
|
97
|
-
for (const task of tbtImpactTasks) {
|
|
98
|
-
const attributableURL = getAttributableURLForTask(task, jsURLs);
|
|
99
|
-
|
|
100
|
-
const urlSummary = byURL.get(attributableURL) || {...defaultSummary};
|
|
101
|
-
const taskDuration = task.selfTime * cpuMultiplier;
|
|
102
|
-
// The amount of time spent on main thread is the sum of all durations.
|
|
103
|
-
urlSummary.mainThreadTime += taskDuration;
|
|
104
|
-
// Blocking time is the amount of time spent on the main thread *over* 50ms.
|
|
105
|
-
// This value is interpolated because not all tasks attributed to this URL are at the top level.
|
|
106
|
-
//
|
|
107
|
-
// Note that this is not totally equivalent to the TBT definition since it fails to account for
|
|
108
|
-
// the FCP&TTI bounds of TBT.
|
|
109
|
-
urlSummary.blockingTime += task.selfBlockingTime;
|
|
110
|
-
// TBT impact is similar to blocking time, but it accounts for the FCP&TTI bounds of TBT.
|
|
111
|
-
urlSummary.tbtImpact += task.selfTbtImpact;
|
|
112
|
-
byURL.set(attributableURL, urlSummary);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Map each URL's stat to a particular entity.
|
|
116
|
-
/** @type {Map<LH.Artifacts.Entity, string[]>} */
|
|
117
|
-
const urls = new Map();
|
|
118
|
-
for (const [url, urlSummary] of byURL.entries()) {
|
|
119
|
-
const entity = entityClassification.entityByUrl.get(url);
|
|
120
|
-
if (!entity) {
|
|
121
|
-
byURL.delete(url);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const entitySummary = byEntity.get(entity) || {...defaultSummary};
|
|
126
|
-
entitySummary.transferSize += urlSummary.transferSize;
|
|
127
|
-
entitySummary.mainThreadTime += urlSummary.mainThreadTime;
|
|
128
|
-
entitySummary.blockingTime += urlSummary.blockingTime;
|
|
129
|
-
entitySummary.tbtImpact += urlSummary.tbtImpact;
|
|
130
|
-
byEntity.set(entity, entitySummary);
|
|
131
|
-
|
|
132
|
-
const entityURLs = urls.get(entity) || [];
|
|
133
|
-
entityURLs.push(url);
|
|
134
|
-
urls.set(entity, entityURLs);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return {byURL, byEntity, urls};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* @param {LH.Artifacts.Entity} entity
|
|
142
|
-
* @param {SummaryMaps} summaries
|
|
143
|
-
* @return {Array<URLSummary>}
|
|
144
|
-
*/
|
|
145
|
-
static makeSubItems(entity, summaries) {
|
|
146
|
-
const entityURLs = summaries.urls.get(entity) || [];
|
|
147
|
-
const items = entityURLs
|
|
148
|
-
.map(url => /** @type {URLSummary} */ ({url, ...summaries.byURL.get(url)}))
|
|
149
|
-
// Sort by blocking time first, then transfer size to break ties.
|
|
150
|
-
.sort((a, b) => (b.blockingTime - a.blockingTime) || (b.transferSize - a.transferSize));
|
|
151
|
-
|
|
152
|
-
return items;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @param {LH.Artifacts} artifacts
|
|
157
|
-
* @param {LH.Audit.Context} context
|
|
158
|
-
* @return {Promise<LH.Audit.Product>}
|
|
159
|
-
*/
|
|
160
|
-
static async audit(artifacts, context) {
|
|
161
|
-
const settings = context.settings || {};
|
|
162
|
-
const devtoolsLog = artifacts.DevtoolsLog;
|
|
163
|
-
const networkRecords = await NetworkRecords.request(devtoolsLog, context);
|
|
164
|
-
const classifiedEntities = await EntityClassification.request(
|
|
165
|
-
{URL: artifacts.URL, devtoolsLog}, context);
|
|
166
|
-
const firstPartyEntity = classifiedEntities.firstParty;
|
|
167
|
-
|
|
168
|
-
const metricComputationData = Audit.makeMetricComputationDataInput(artifacts, context);
|
|
169
|
-
const tbtImpactTasks = await TBTImpactTasks.request(metricComputationData, context);
|
|
170
|
-
|
|
171
|
-
const multiplier = settings.throttlingMethod === 'simulate' ?
|
|
172
|
-
settings.throttling.cpuSlowdownMultiplier : 1;
|
|
173
|
-
|
|
174
|
-
const summaries = ThirdPartySummary.getSummaries(
|
|
175
|
-
networkRecords, tbtImpactTasks, multiplier, classifiedEntities);
|
|
176
|
-
const overallSummary = {wastedBytes: 0, wastedMs: 0, tbtImpact: 0};
|
|
177
|
-
|
|
178
|
-
const results = Array.from(summaries.byEntity.entries())
|
|
179
|
-
// Don't consider the page we're on to be third-party.
|
|
180
|
-
// e.g. Facebook SDK isn't a third-party script on facebook.com
|
|
181
|
-
.filter(([entity]) => !(firstPartyEntity && firstPartyEntity === entity))
|
|
182
|
-
.map(([entity, stats]) => {
|
|
183
|
-
overallSummary.wastedBytes += stats.transferSize;
|
|
184
|
-
overallSummary.wastedMs += stats.blockingTime;
|
|
185
|
-
overallSummary.tbtImpact += stats.tbtImpact;
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
...stats,
|
|
189
|
-
entity: entity.name,
|
|
190
|
-
subItems: {
|
|
191
|
-
type: /** @type {const} */ ('subitems'),
|
|
192
|
-
items: ThirdPartySummary.makeSubItems(entity, summaries),
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
})
|
|
196
|
-
// Sort by blocking time first, then transfer size to break ties.
|
|
197
|
-
.sort((a, b) => (b.blockingTime - a.blockingTime) || (b.transferSize - a.transferSize));
|
|
198
|
-
|
|
199
|
-
/** @type {LH.Audit.Details.Table['headings']} */
|
|
200
|
-
const headings = [
|
|
201
|
-
/* eslint-disable max-len */
|
|
202
|
-
{key: 'entity', valueType: 'text', label: str_(UIStrings.columnThirdParty), subItemsHeading: {key: 'url', valueType: 'url'}},
|
|
203
|
-
{key: 'transferSize', granularity: 1, valueType: 'bytes', label: str_(i18n.UIStrings.columnTransferSize), subItemsHeading: {key: 'transferSize'}},
|
|
204
|
-
{key: 'blockingTime', granularity: 1, valueType: 'ms', label: str_(i18n.UIStrings.columnBlockingTime), subItemsHeading: {key: 'blockingTime'}},
|
|
205
|
-
/* eslint-enable max-len */
|
|
206
|
-
];
|
|
207
|
-
|
|
208
|
-
if (!results.length) {
|
|
209
|
-
return {
|
|
210
|
-
score: 1,
|
|
211
|
-
notApplicable: true,
|
|
212
|
-
metricSavings: {TBT: 0},
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const details = Audit.makeTableDetails(headings, results,
|
|
217
|
-
{...overallSummary, isEntityGrouped: true});
|
|
218
|
-
|
|
219
|
-
const passed = overallSummary.wastedMs <= PASS_THRESHOLD_IN_MS;
|
|
220
|
-
|
|
221
|
-
return {
|
|
222
|
-
score: Number(passed),
|
|
223
|
-
scoreDisplayMode: passed ? Audit.SCORING_MODES.INFORMATIVE : undefined,
|
|
224
|
-
displayValue: str_(UIStrings.displayValue, {
|
|
225
|
-
timeInMs: overallSummary.wastedMs,
|
|
226
|
-
}),
|
|
227
|
-
details,
|
|
228
|
-
metricSavings: {
|
|
229
|
-
TBT: Math.round(overallSummary.tbtImpact),
|
|
230
|
-
},
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export default ThirdPartySummary;
|
|
236
|
-
export {UIStrings};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export default UsesRelPreconnectAudit;
|
|
2
|
-
declare class UsesRelPreconnectAudit extends Audit {
|
|
3
|
-
/**
|
|
4
|
-
* Check if record has valid timing
|
|
5
|
-
* @param {LH.Artifacts.NetworkRequest} record
|
|
6
|
-
* @return {boolean}
|
|
7
|
-
*/
|
|
8
|
-
static hasValidTiming(record: LH.Artifacts.NetworkRequest): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Check is the connection is already open
|
|
11
|
-
* @param {LH.Artifacts.NetworkRequest} record
|
|
12
|
-
* @return {boolean}
|
|
13
|
-
*/
|
|
14
|
-
static hasAlreadyConnectedToOrigin(record: LH.Artifacts.NetworkRequest): boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Check is the connection has started before the socket idle time
|
|
17
|
-
* @param {LH.Artifacts.NetworkRequest} record
|
|
18
|
-
* @param {LH.Artifacts.NetworkRequest} mainResource
|
|
19
|
-
* @return {boolean}
|
|
20
|
-
*/
|
|
21
|
-
static socketStartTimeIsBelowThreshold(record: LH.Artifacts.NetworkRequest, mainResource: LH.Artifacts.NetworkRequest): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* @param {LH.Artifacts} artifacts
|
|
24
|
-
* @param {LH.Audit.Context} context
|
|
25
|
-
* @return {Promise<LH.Audit.Product>}
|
|
26
|
-
*/
|
|
27
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
28
|
-
}
|
|
29
|
-
export namespace UIStrings {
|
|
30
|
-
let title: string;
|
|
31
|
-
let description: string;
|
|
32
|
-
let unusedWarning: string;
|
|
33
|
-
let crossoriginWarning: string;
|
|
34
|
-
let tooManyPreconnectLinksWarning: string;
|
|
35
|
-
}
|
|
36
|
-
import { Audit } from './audit.js';
|
|
37
|
-
//# sourceMappingURL=uses-rel-preconnect.d.ts.map
|