lighthouse 12.8.2 → 13.0.0-dev.20251010
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,44 +0,0 @@
|
|
|
1
|
-
export default CriticalRequestChains;
|
|
2
|
-
declare class CriticalRequestChains extends Audit {
|
|
3
|
-
/** @typedef {{depth: number, id: string, chainDuration: number, chainTransferSize: number, node: LH.Artifacts.CriticalRequestNode[string]}} CrcNodeInfo */
|
|
4
|
-
/**
|
|
5
|
-
* @param {LH.Artifacts.CriticalRequestNode} tree
|
|
6
|
-
* @param {function(CrcNodeInfo): void} cb
|
|
7
|
-
*/
|
|
8
|
-
static _traverse(tree: LH.Artifacts.CriticalRequestNode, cb: (arg0: {
|
|
9
|
-
depth: number;
|
|
10
|
-
id: string;
|
|
11
|
-
chainDuration: number;
|
|
12
|
-
chainTransferSize: number;
|
|
13
|
-
node: LH.Artifacts.CriticalRequestNode[string];
|
|
14
|
-
}) => void): void;
|
|
15
|
-
/**
|
|
16
|
-
* Get stats about the longest initiator chain (as determined by time duration)
|
|
17
|
-
* @param {LH.Artifacts.CriticalRequestNode} tree
|
|
18
|
-
* @return {{duration: number, length: number, transferSize: number}}
|
|
19
|
-
*/
|
|
20
|
-
static _getLongestChain(tree: LH.Artifacts.CriticalRequestNode): {
|
|
21
|
-
duration: number;
|
|
22
|
-
length: number;
|
|
23
|
-
transferSize: number;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* @param {LH.Artifacts.CriticalRequestNode} tree
|
|
27
|
-
* @return {LH.Audit.Details.SimpleCriticalRequestNode}
|
|
28
|
-
*/
|
|
29
|
-
static flattenRequests(tree: LH.Artifacts.CriticalRequestNode): LH.Audit.Details.SimpleCriticalRequestNode;
|
|
30
|
-
/**
|
|
31
|
-
* Audits the page to give a score for First Meaningful Paint.
|
|
32
|
-
* @param {LH.Artifacts} artifacts The artifacts from the gather phase.
|
|
33
|
-
* @param {LH.Audit.Context} context
|
|
34
|
-
* @return {Promise<LH.Audit.Product>}
|
|
35
|
-
*/
|
|
36
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
37
|
-
}
|
|
38
|
-
export namespace UIStrings {
|
|
39
|
-
let title: string;
|
|
40
|
-
let description: string;
|
|
41
|
-
let displayValue: string;
|
|
42
|
-
}
|
|
43
|
-
import { Audit } from './audit.js';
|
|
44
|
-
//# sourceMappingURL=critical-request-chains.d.ts.map
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2016 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import {Audit} from './audit.js';
|
|
8
|
-
import * as i18n from '../lib/i18n/i18n.js';
|
|
9
|
-
import {CriticalRequestChains as ComputedChains} from '../computed/critical-request-chains.js';
|
|
10
|
-
|
|
11
|
-
const UIStrings = {
|
|
12
|
-
/** Imperative title of a Lighthouse audit that tells the user to reduce the depth of critical network requests to enhance initial load of a page. Critical request chains are series of dependent network requests that are important for page rendering. For example, here's a 4-request-deep chain: The biglogo.jpg image is required, but is requested via the styles.css style code, which is requested by the initialize.js javascript, which is requested by the page's HTML. This is displayed in a list of audit titles that Lighthouse generates. */
|
|
13
|
-
title: 'Avoid chaining critical requests',
|
|
14
|
-
/** Description of a Lighthouse audit that tells the user *why* they should reduce the depth of critical network requests to enhance initial load of a page . 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. */
|
|
15
|
-
description: 'The Critical Request Chains below show you what resources are ' +
|
|
16
|
-
'loaded with a high priority. Consider reducing ' +
|
|
17
|
-
'the length of chains, reducing the download size of resources, or ' +
|
|
18
|
-
'deferring the download of unnecessary resources to improve page load. ' +
|
|
19
|
-
'[Learn how to avoid chaining critical requests](https://developer.chrome.com/docs/lighthouse/performance/critical-request-chains/).',
|
|
20
|
-
/** [ICU Syntax] Label for an audit identifying the number of sequences of dependent network requests used to load the page. */
|
|
21
|
-
displayValue: `{itemCount, plural,
|
|
22
|
-
=1 {1 chain found}
|
|
23
|
-
other {# chains found}
|
|
24
|
-
}`,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
28
|
-
|
|
29
|
-
class CriticalRequestChains extends Audit {
|
|
30
|
-
/**
|
|
31
|
-
* @return {LH.Audit.Meta}
|
|
32
|
-
*/
|
|
33
|
-
static get meta() {
|
|
34
|
-
return {
|
|
35
|
-
id: 'critical-request-chains',
|
|
36
|
-
title: str_(UIStrings.title),
|
|
37
|
-
description: str_(UIStrings.description),
|
|
38
|
-
scoreDisplayMode: Audit.SCORING_MODES.INFORMATIVE,
|
|
39
|
-
supportedModes: ['navigation'],
|
|
40
|
-
guidanceLevel: 1,
|
|
41
|
-
requiredArtifacts: ['Trace', 'DevtoolsLog', 'URL', 'SourceMaps'],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** @typedef {{depth: number, id: string, chainDuration: number, chainTransferSize: number, node: LH.Artifacts.CriticalRequestNode[string]}} CrcNodeInfo */
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @param {LH.Artifacts.CriticalRequestNode} tree
|
|
49
|
-
* @param {function(CrcNodeInfo): void} cb
|
|
50
|
-
*/
|
|
51
|
-
static _traverse(tree, cb) {
|
|
52
|
-
/**
|
|
53
|
-
* @param {LH.Artifacts.CriticalRequestNode} node
|
|
54
|
-
* @param {number} depth
|
|
55
|
-
* @param {number=} networkRequestTime
|
|
56
|
-
* @param {number=} transferSize
|
|
57
|
-
*/
|
|
58
|
-
function walk(node, depth, networkRequestTime, transferSize = 0) {
|
|
59
|
-
const children = Object.keys(node);
|
|
60
|
-
if (children.length === 0) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
children.forEach(id => {
|
|
64
|
-
const child = node[id];
|
|
65
|
-
if (!networkRequestTime) {
|
|
66
|
-
networkRequestTime = child.request.networkRequestTime;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Call the callback with the info for this child.
|
|
70
|
-
cb({
|
|
71
|
-
depth,
|
|
72
|
-
id,
|
|
73
|
-
node: child,
|
|
74
|
-
chainDuration: child.request.networkEndTime - networkRequestTime,
|
|
75
|
-
chainTransferSize: transferSize + child.request.transferSize,
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Carry on walking.
|
|
79
|
-
if (child.children) {
|
|
80
|
-
walk(child.children, depth + 1, networkRequestTime);
|
|
81
|
-
}
|
|
82
|
-
}, '');
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
walk(tree, 0);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get stats about the longest initiator chain (as determined by time duration)
|
|
90
|
-
* @param {LH.Artifacts.CriticalRequestNode} tree
|
|
91
|
-
* @return {{duration: number, length: number, transferSize: number}}
|
|
92
|
-
*/
|
|
93
|
-
static _getLongestChain(tree) {
|
|
94
|
-
const longest = {
|
|
95
|
-
duration: 0,
|
|
96
|
-
length: 0,
|
|
97
|
-
transferSize: 0,
|
|
98
|
-
};
|
|
99
|
-
CriticalRequestChains._traverse(tree, opts => {
|
|
100
|
-
const duration = opts.chainDuration;
|
|
101
|
-
if (duration > longest.duration) {
|
|
102
|
-
longest.duration = duration;
|
|
103
|
-
longest.transferSize = opts.chainTransferSize;
|
|
104
|
-
longest.length = opts.depth;
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
// Always return the longest chain + 1 because the depth is zero indexed.
|
|
108
|
-
longest.length++;
|
|
109
|
-
return longest;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* @param {LH.Artifacts.CriticalRequestNode} tree
|
|
114
|
-
* @return {LH.Audit.Details.SimpleCriticalRequestNode}
|
|
115
|
-
*/
|
|
116
|
-
static flattenRequests(tree) {
|
|
117
|
-
/** @type {LH.Audit.Details.SimpleCriticalRequestNode} */
|
|
118
|
-
const flattendChains = {};
|
|
119
|
-
/** @type {Map<string, LH.Audit.Details.SimpleCriticalRequestNode[string]>} */
|
|
120
|
-
const chainMap = new Map();
|
|
121
|
-
|
|
122
|
-
/** @param {CrcNodeInfo} opts */
|
|
123
|
-
function flatten(opts) {
|
|
124
|
-
const request = opts.node.request;
|
|
125
|
-
const simpleRequest = {
|
|
126
|
-
url: request.url,
|
|
127
|
-
startTime: request.networkRequestTime / 1000,
|
|
128
|
-
endTime: request.networkEndTime / 1000,
|
|
129
|
-
responseReceivedTime: request.responseHeadersEndTime / 1000,
|
|
130
|
-
transferSize: request.transferSize,
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
let chain = chainMap.get(opts.id);
|
|
134
|
-
if (chain) {
|
|
135
|
-
chain.request = simpleRequest;
|
|
136
|
-
} else {
|
|
137
|
-
chain = {
|
|
138
|
-
request: simpleRequest,
|
|
139
|
-
};
|
|
140
|
-
flattendChains[opts.id] = chain;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
if (opts.node.children) {
|
|
144
|
-
for (const chainId of Object.keys(opts.node.children)) {
|
|
145
|
-
// Note: cast should be Partial<>, but filled in when child node is traversed.
|
|
146
|
-
const childChain = /** @type {LH.Audit.Details.SimpleCriticalRequestNode[string]} */ ({
|
|
147
|
-
request: {},
|
|
148
|
-
});
|
|
149
|
-
chainMap.set(chainId, childChain);
|
|
150
|
-
if (!chain.children) {
|
|
151
|
-
chain.children = {};
|
|
152
|
-
}
|
|
153
|
-
chain.children[chainId] = childChain;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
chainMap.set(opts.id, chain);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
CriticalRequestChains._traverse(tree, flatten);
|
|
160
|
-
|
|
161
|
-
return flattendChains;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Audits the page to give a score for First Meaningful Paint.
|
|
166
|
-
* @param {LH.Artifacts} artifacts The artifacts from the gather phase.
|
|
167
|
-
* @param {LH.Audit.Context} context
|
|
168
|
-
* @return {Promise<LH.Audit.Product>}
|
|
169
|
-
*/
|
|
170
|
-
static async audit(artifacts, context) {
|
|
171
|
-
const settings = context.settings;
|
|
172
|
-
const trace = artifacts.Trace;
|
|
173
|
-
const devtoolsLog = artifacts.DevtoolsLog;
|
|
174
|
-
const {URL, SourceMaps} = artifacts;
|
|
175
|
-
const chains =
|
|
176
|
-
await ComputedChains.request({settings, devtoolsLog, trace, URL, SourceMaps}, context);
|
|
177
|
-
let chainCount = 0;
|
|
178
|
-
/**
|
|
179
|
-
* @param {LH.Audit.Details.SimpleCriticalRequestNode} node
|
|
180
|
-
* @param {number} depth
|
|
181
|
-
*/
|
|
182
|
-
function walk(node, depth) {
|
|
183
|
-
const childIds = Object.keys(node);
|
|
184
|
-
|
|
185
|
-
childIds.forEach(id => {
|
|
186
|
-
const child = node[id];
|
|
187
|
-
if (child.children) {
|
|
188
|
-
walk(child.children, depth + 1);
|
|
189
|
-
} else {
|
|
190
|
-
// if the node doesn't have a children field, then it is a leaf, so +1
|
|
191
|
-
chainCount++;
|
|
192
|
-
}
|
|
193
|
-
}, '');
|
|
194
|
-
}
|
|
195
|
-
// Convert
|
|
196
|
-
const flattenedChains = CriticalRequestChains.flattenRequests(chains);
|
|
197
|
-
|
|
198
|
-
// Account for initial navigation
|
|
199
|
-
const initialNavKey = Object.keys(flattenedChains)[0];
|
|
200
|
-
const initialNavChildren = initialNavKey && flattenedChains[initialNavKey].children;
|
|
201
|
-
if (initialNavChildren && Object.keys(initialNavChildren).length > 0) {
|
|
202
|
-
walk(initialNavChildren, 0);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const longestChain = CriticalRequestChains._getLongestChain(chains);
|
|
206
|
-
|
|
207
|
-
return {
|
|
208
|
-
score: Number(chainCount === 0),
|
|
209
|
-
notApplicable: chainCount === 0,
|
|
210
|
-
displayValue: chainCount ? str_(UIStrings.displayValue, {itemCount: chainCount}) : '',
|
|
211
|
-
details: {
|
|
212
|
-
type: 'criticalrequestchain',
|
|
213
|
-
chains: flattenedChains,
|
|
214
|
-
longestChain,
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export default CriticalRequestChains;
|
|
221
|
-
export {UIStrings};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export default DOMSize;
|
|
2
|
-
declare class DOMSize extends Audit {
|
|
3
|
-
/**
|
|
4
|
-
* @return {LH.Audit.ScoreOptions}
|
|
5
|
-
*/
|
|
6
|
-
static get defaultOptions(): LH.Audit.ScoreOptions;
|
|
7
|
-
/**
|
|
8
|
-
* @param {LH.Artifacts} artifacts
|
|
9
|
-
* @param {LH.Audit.Context} context
|
|
10
|
-
* @return {Promise<number|undefined>}
|
|
11
|
-
*/
|
|
12
|
-
static computeTbtImpact(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<number | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* @param {LH.Artifacts} artifacts
|
|
15
|
-
* @param {LH.Audit.Context} context
|
|
16
|
-
* @return {Promise<LH.Audit.Product>}
|
|
17
|
-
*/
|
|
18
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
19
|
-
}
|
|
20
|
-
export namespace UIStrings {
|
|
21
|
-
let title: string;
|
|
22
|
-
let failureTitle: string;
|
|
23
|
-
let description: string;
|
|
24
|
-
let columnStatistic: string;
|
|
25
|
-
let columnValue: string;
|
|
26
|
-
let displayValue: string;
|
|
27
|
-
let statisticDOMElements: string;
|
|
28
|
-
let statisticDOMDepth: string;
|
|
29
|
-
let statisticDOMWidth: string;
|
|
30
|
-
}
|
|
31
|
-
import { Audit } from '../audit.js';
|
|
32
|
-
//# sourceMappingURL=dom-size.d.ts.map
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2017 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview Audits a page to see how the size of DOM it creates. Stats like
|
|
9
|
-
* tree depth, # children, and total elements are returned. The score is calculated
|
|
10
|
-
* based solely on the total number of elements found on the page.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {Audit} from '../audit.js';
|
|
15
|
-
import * as i18n from '../../lib/i18n/i18n.js';
|
|
16
|
-
import {TBTImpactTasks} from '../../computed/tbt-impact-tasks.js';
|
|
17
|
-
|
|
18
|
-
const UIStrings = {
|
|
19
|
-
/** Title of a diagnostic audit that provides detail on the size of the web page's DOM. The size of a DOM is characterized by the total number of DOM elements and greatest DOM depth. This descriptive title is shown to users when the amount is acceptable and no user action is required. */
|
|
20
|
-
title: 'Avoids an excessive DOM size',
|
|
21
|
-
/** Title of a diagnostic audit that provides detail on the size of the web page's DOM. The size of a DOM is characterized by the total number of DOM elements and greatest DOM depth. This imperative title is shown to users when there is a significant amount of execution time that could be reduced. */
|
|
22
|
-
failureTitle: 'Avoid an excessive DOM size',
|
|
23
|
-
/** Description of a Lighthouse audit that tells the user *why* they should reduce the size of the web page's DOM. The size of a DOM is characterized by the total number of DOM elements and greatest DOM depth. 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. */
|
|
24
|
-
description: 'A large DOM will increase memory usage, cause longer ' +
|
|
25
|
-
'[style calculations](https://developers.google.com/web/fundamentals/performance/rendering/reduce-the-scope-and-complexity-of-style-calculations), ' +
|
|
26
|
-
'and produce costly [layout reflows](https://developers.google.com/speed/articles/reflow). [Learn how to avoid an excessive DOM size](https://developer.chrome.com/docs/lighthouse/performance/dom-size/).',
|
|
27
|
-
/** Table column header for the type of statistic. These statistics describe how big the DOM is (count of DOM elements, children, depth). */
|
|
28
|
-
columnStatistic: 'Statistic',
|
|
29
|
-
/** Table column header for the observed value of the DOM statistic. */
|
|
30
|
-
columnValue: 'Value',
|
|
31
|
-
/** [ICU Syntax] Label for an audit identifying the number of DOM elements found in the page. */
|
|
32
|
-
displayValue: `{itemCount, plural,
|
|
33
|
-
=1 {1 element}
|
|
34
|
-
other {# elements}
|
|
35
|
-
}`,
|
|
36
|
-
/** Label for the total number of DOM elements found in the page. */
|
|
37
|
-
statisticDOMElements: 'Total DOM Elements',
|
|
38
|
-
/** Label for the numeric value of the maximum depth in the page's DOM tree. */
|
|
39
|
-
statisticDOMDepth: 'Maximum DOM Depth',
|
|
40
|
-
/** Label for the numeric value of the maximum number of children any DOM element in the page has. The element described will have the most children in the page. */
|
|
41
|
-
statisticDOMWidth: 'Maximum Child Elements',
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
45
|
-
|
|
46
|
-
class DOMSize extends Audit {
|
|
47
|
-
/**
|
|
48
|
-
* @return {LH.Audit.Meta}
|
|
49
|
-
*/
|
|
50
|
-
static get meta() {
|
|
51
|
-
return {
|
|
52
|
-
id: 'dom-size',
|
|
53
|
-
title: str_(UIStrings.title),
|
|
54
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
55
|
-
description: str_(UIStrings.description),
|
|
56
|
-
scoreDisplayMode: Audit.SCORING_MODES.METRIC_SAVINGS,
|
|
57
|
-
guidanceLevel: 1,
|
|
58
|
-
requiredArtifacts: ['DOMStats', 'URL', 'GatherContext'],
|
|
59
|
-
__internalOptionalArtifacts: ['Trace', 'DevtoolsLog', 'SourceMaps'],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* @return {LH.Audit.ScoreOptions}
|
|
65
|
-
*/
|
|
66
|
-
static get defaultOptions() {
|
|
67
|
-
return {
|
|
68
|
-
// https://bigquery.cloud.google.com/table/httparchive:lighthouse.2018_04_01_mobile?pli=1
|
|
69
|
-
// see https://www.desmos.com/calculator/tsunbwqt3f
|
|
70
|
-
p10: 818,
|
|
71
|
-
median: 1400,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @param {LH.Artifacts} artifacts
|
|
77
|
-
* @param {LH.Audit.Context} context
|
|
78
|
-
* @return {Promise<number|undefined>}
|
|
79
|
-
*/
|
|
80
|
-
static async computeTbtImpact(artifacts, context) {
|
|
81
|
-
let tbtImpact = 0;
|
|
82
|
-
|
|
83
|
-
// We still want to surface this audit in snapshot mode, but since we don't compute TBT
|
|
84
|
-
// the impact should always be undefined.
|
|
85
|
-
const {GatherContext, DevtoolsLog, Trace} = artifacts;
|
|
86
|
-
if (GatherContext.gatherMode !== 'navigation') {
|
|
87
|
-
return undefined;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Since the artifacts are optional, it's still possible for them to be missing in navigation mode.
|
|
91
|
-
// Navigation mode does compute TBT so we should surface a numerical savings of 0.
|
|
92
|
-
if (!DevtoolsLog || !Trace) {
|
|
93
|
-
return 0;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const metricComputationData = Audit.makeMetricComputationDataInput(artifacts, context);
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
// The TBT impact of style/layout tasks is correlated to the DOM size.
|
|
100
|
-
// Even in situations where the page forces a style recalc, the DOM size is partially to blame
|
|
101
|
-
// for any time spent blocking the main thread.
|
|
102
|
-
//
|
|
103
|
-
// `tbtImpact` should be exactly 0 for small DOMs since `selfTbtImpact` accounts for the blocking
|
|
104
|
-
// time and not the main thread time.
|
|
105
|
-
const tbtImpactTasks = await TBTImpactTasks.request(metricComputationData, context);
|
|
106
|
-
for (const task of tbtImpactTasks) {
|
|
107
|
-
if (task.group.id !== 'styleLayout') continue;
|
|
108
|
-
tbtImpact += task.selfTbtImpact;
|
|
109
|
-
}
|
|
110
|
-
} catch {}
|
|
111
|
-
|
|
112
|
-
return Math.round(tbtImpact);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @param {LH.Artifacts} artifacts
|
|
118
|
-
* @param {LH.Audit.Context} context
|
|
119
|
-
* @return {Promise<LH.Audit.Product>}
|
|
120
|
-
*/
|
|
121
|
-
static async audit(artifacts, context) {
|
|
122
|
-
const stats = artifacts.DOMStats;
|
|
123
|
-
|
|
124
|
-
const score = Audit.computeLogNormalScore(
|
|
125
|
-
{p10: context.options.p10, median: context.options.median},
|
|
126
|
-
stats.totalBodyElements
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
/** @type {LH.Audit.Details.Table['headings']} */
|
|
130
|
-
const headings = [
|
|
131
|
-
{key: 'statistic', valueType: 'text', label: str_(UIStrings.columnStatistic)},
|
|
132
|
-
{key: 'node', valueType: 'node', label: str_(i18n.UIStrings.columnElement)},
|
|
133
|
-
{key: 'value', valueType: 'numeric', label: str_(UIStrings.columnValue)},
|
|
134
|
-
];
|
|
135
|
-
|
|
136
|
-
/** @type {LH.Audit.Details.Table['items']} */
|
|
137
|
-
const items = [
|
|
138
|
-
{
|
|
139
|
-
statistic: str_(UIStrings.statisticDOMElements),
|
|
140
|
-
value: {
|
|
141
|
-
type: 'numeric',
|
|
142
|
-
granularity: 1,
|
|
143
|
-
value: stats.totalBodyElements,
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
node: Audit.makeNodeItem(stats.depth),
|
|
148
|
-
statistic: str_(UIStrings.statisticDOMDepth),
|
|
149
|
-
value: {
|
|
150
|
-
type: 'numeric',
|
|
151
|
-
granularity: 1,
|
|
152
|
-
value: stats.depth.max,
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
node: Audit.makeNodeItem(stats.width),
|
|
157
|
-
statistic: str_(UIStrings.statisticDOMWidth),
|
|
158
|
-
value: {
|
|
159
|
-
type: 'numeric',
|
|
160
|
-
granularity: 1,
|
|
161
|
-
value: stats.width.max,
|
|
162
|
-
},
|
|
163
|
-
},
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
const tbtImpact = await this.computeTbtImpact(artifacts, context);
|
|
167
|
-
|
|
168
|
-
return {
|
|
169
|
-
score,
|
|
170
|
-
numericValue: stats.totalBodyElements,
|
|
171
|
-
numericUnit: 'element',
|
|
172
|
-
displayValue: str_(UIStrings.displayValue, {itemCount: stats.totalBodyElements}),
|
|
173
|
-
details: Audit.makeTableDetails(headings, items),
|
|
174
|
-
metricSavings: {
|
|
175
|
-
TBT: tbtImpact,
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export default DOMSize;
|
|
182
|
-
export {UIStrings};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export default NoDocWriteAudit;
|
|
2
|
-
declare class NoDocWriteAudit extends ViolationAudit {
|
|
3
|
-
/**
|
|
4
|
-
* @param {LH.Artifacts} artifacts
|
|
5
|
-
* @param {LH.Audit.Context} context
|
|
6
|
-
* @return {Promise<LH.Audit.Product>}
|
|
7
|
-
*/
|
|
8
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
9
|
-
}
|
|
10
|
-
export namespace UIStrings {
|
|
11
|
-
let title: string;
|
|
12
|
-
let failureTitle: string;
|
|
13
|
-
let description: string;
|
|
14
|
-
}
|
|
15
|
-
import ViolationAudit from '../violation-audit.js';
|
|
16
|
-
//# sourceMappingURL=no-document-write.d.ts.map
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2016 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @fileoverview Audit a page to see if it's using document.write(). document.write() has terrible performance characteristics.
|
|
9
|
-
*
|
|
10
|
-
* *Intervention*
|
|
11
|
-
* There is a Chrome intervention for the API: https://developers.google.com/web/updates/2016/08/removing-document-write
|
|
12
|
-
* The intervention appears to only be enabled when the user is on a slow connnection. https://chromestatus.com/features#document.write
|
|
13
|
-
* When it's enabled, _some_ calls to document.write() will just not do anything. They're just no-ops.
|
|
14
|
-
* - "some" == mostly third-party situations. src: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/script/document_write_intervention.cc?l=109&rcl=61a806621861e9abc07b3a57a6f2edae188d1742
|
|
15
|
-
* If this happens, there will be an error message in the console. src: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/script/document_write_intervention.cc?l=51-61&rcl=61a806621861e9abc07b3a57a6f2edae188d1742
|
|
16
|
-
* - Lighthouse doesn't report here on that situation, though it'll show up in `errors-in-console`
|
|
17
|
-
* The intervention may also not block the .write() (because the connection wasn't slow),
|
|
18
|
-
* but it will emit a console warning.
|
|
19
|
-
* - Lighthouse will also report that here, as the .write() call succeeded.
|
|
20
|
-
* Demo URL: https://output.jsbin.com/qopijux/quiet
|
|
21
|
-
*
|
|
22
|
-
* *This Audit*
|
|
23
|
-
* This audit reports on document.write() calls which the intervention didn't stop.
|
|
24
|
-
* (They worked as intended). If that happens, the browser emits a verbose-level violation
|
|
25
|
-
* console message (hidden by default) that says:
|
|
26
|
-
* "Parser was blocked due to document.write(<script>)". src: https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/frame/performance_monitor.cc?l=294-300&rcl=40b90cafad9f219e0845879ed8648bdcc96116dc
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import ViolationAudit from '../violation-audit.js';
|
|
31
|
-
import * as i18n from '../../lib/i18n/i18n.js';
|
|
32
|
-
|
|
33
|
-
const UIStrings = {
|
|
34
|
-
/** Title of a Lighthouse audit that provides detail on the page's use of the `document.write` API. This descriptive title is shown to users when the page does not use `document.write`. */
|
|
35
|
-
title: 'Avoids `document.write()`',
|
|
36
|
-
/** Title of a Lighthouse audit that provides detail on the page's use of the `document.write` API. This imperative title is shown to users when the page does use `document.write`. */
|
|
37
|
-
failureTitle: 'Avoid `document.write()`',
|
|
38
|
-
/** Description of a Lighthouse audit that tells the user why they should avoid `document.write`. 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. */
|
|
39
|
-
description: 'For users on slow connections, external scripts dynamically injected via ' +
|
|
40
|
-
'`document.write()` can delay page load by tens of seconds. ' +
|
|
41
|
-
'[Learn how to avoid document.write()](https://developer.chrome.com/docs/lighthouse/best-practices/no-document-write/).',
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const str_ = i18n.createIcuMessageFn(import.meta.url, UIStrings);
|
|
45
|
-
|
|
46
|
-
class NoDocWriteAudit extends ViolationAudit {
|
|
47
|
-
/**
|
|
48
|
-
* @return {LH.Audit.Meta}
|
|
49
|
-
*/
|
|
50
|
-
static get meta() {
|
|
51
|
-
return {
|
|
52
|
-
id: 'no-document-write',
|
|
53
|
-
title: str_(UIStrings.title),
|
|
54
|
-
failureTitle: str_(UIStrings.failureTitle),
|
|
55
|
-
description: str_(UIStrings.description),
|
|
56
|
-
guidanceLevel: 2,
|
|
57
|
-
requiredArtifacts: ['ConsoleMessages', 'SourceMaps', 'Scripts'],
|
|
58
|
-
scoreDisplayMode: ViolationAudit.SCORING_MODES.METRIC_SAVINGS,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @param {LH.Artifacts} artifacts
|
|
64
|
-
* @param {LH.Audit.Context} context
|
|
65
|
-
* @return {Promise<LH.Audit.Product>}
|
|
66
|
-
*/
|
|
67
|
-
static async audit(artifacts, context) {
|
|
68
|
-
const results =
|
|
69
|
-
await ViolationAudit.getViolationResults(artifacts, context, /document\.write/);
|
|
70
|
-
|
|
71
|
-
/** @type {LH.Audit.Details.Table['headings']} */
|
|
72
|
-
const headings = [
|
|
73
|
-
{key: 'source', valueType: 'source-location', label: str_(i18n.UIStrings.columnSource)},
|
|
74
|
-
];
|
|
75
|
-
// TODO(bckenny): see TODO in geolocation-on-start
|
|
76
|
-
const details = ViolationAudit.makeTableDetails(headings, results);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
score: Number(results.length === 0),
|
|
80
|
-
details,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export default NoDocWriteAudit;
|
|
86
|
-
export {UIStrings};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export default UsesHTTP2Audit;
|
|
2
|
-
declare class UsesHTTP2Audit extends Audit {
|
|
3
|
-
/**
|
|
4
|
-
* Computes the estimated effect of all results being converted to http/2 on the provided graph.
|
|
5
|
-
*
|
|
6
|
-
* @param {Array<{url: string}>} results
|
|
7
|
-
* @param {LH.Gatherer.Simulation.GraphNode} graph
|
|
8
|
-
* @param {LH.Gatherer.Simulation.Simulator} simulator
|
|
9
|
-
* @param {{label?: string}=} options
|
|
10
|
-
* @return {{savings: number, simulationBefore: LH.Gatherer.Simulation.Result, simulationAfter: LH.Gatherer.Simulation.Result}}
|
|
11
|
-
*/
|
|
12
|
-
static computeWasteWithGraph(results: Array<{
|
|
13
|
-
url: string;
|
|
14
|
-
}>, graph: LH.Gatherer.Simulation.GraphNode, simulator: LH.Gatherer.Simulation.Simulator, options?: {
|
|
15
|
-
label?: string;
|
|
16
|
-
} | undefined): {
|
|
17
|
-
savings: number;
|
|
18
|
-
simulationBefore: LH.Gatherer.Simulation.Result;
|
|
19
|
-
simulationAfter: LH.Gatherer.Simulation.Result;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Determines whether a network request is a "static resource" that would benefit from H2 multiplexing.
|
|
23
|
-
* XHRs, tracking pixels, etc generally don't benefit as much because they aren't requested en-masse
|
|
24
|
-
* for the same origin at the exact same time.
|
|
25
|
-
*
|
|
26
|
-
* @param {LH.Artifacts.NetworkRequest} networkRequest
|
|
27
|
-
* @param {LH.Artifacts.EntityClassification} classifiedEntities
|
|
28
|
-
* @return {boolean}
|
|
29
|
-
*/
|
|
30
|
-
static isMultiplexableStaticAsset(networkRequest: LH.Artifacts.NetworkRequest, classifiedEntities: LH.Artifacts.EntityClassification): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Determine the set of resources that aren't HTTP/2 but should be.
|
|
33
|
-
* We're a little conservative about what we surface for a few reasons:
|
|
34
|
-
*
|
|
35
|
-
* - The simulator approximation of HTTP/2 is a little more generous than reality.
|
|
36
|
-
* - There's a bit of debate surrounding HTTP/2 due to its worse performance in environments with high packet loss.**
|
|
37
|
-
* - It's something that you'd have absolutely zero control over with a third-party (can't defer to fix it for example).
|
|
38
|
-
*
|
|
39
|
-
* Therefore, we only surface requests that were...
|
|
40
|
-
*
|
|
41
|
-
* - Served over HTTP/1.1 or earlier
|
|
42
|
-
* - Served over an origin that serves at least 6 static asset requests
|
|
43
|
-
* (if there aren't more requests than browser's max/host, multiplexing isn't as big a deal)
|
|
44
|
-
* - Not served on localhost (h2 is a pain to deal with locally & and CI)
|
|
45
|
-
*
|
|
46
|
-
* ** = https://news.ycombinator.com/item?id=19086639
|
|
47
|
-
* https://www.twilio.com/blog/2017/10/http2-issues.html
|
|
48
|
-
* https://www.cachefly.com/http-2-is-not-a-magic-bullet/
|
|
49
|
-
*
|
|
50
|
-
* @param {Array<LH.Artifacts.NetworkRequest>} networkRecords
|
|
51
|
-
* @param {LH.Artifacts.EntityClassification} classifiedEntities
|
|
52
|
-
* @return {Array<{url: string, protocol: string}>}
|
|
53
|
-
*/
|
|
54
|
-
static determineNonHttp2Resources(networkRecords: Array<LH.Artifacts.NetworkRequest>, classifiedEntities: LH.Artifacts.EntityClassification): Array<{
|
|
55
|
-
url: string;
|
|
56
|
-
protocol: string;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* @param {LH.Artifacts} artifacts
|
|
60
|
-
* @param {LH.Audit.Context} context
|
|
61
|
-
* @return {Promise<LH.Audit.Product>}
|
|
62
|
-
*/
|
|
63
|
-
static audit(artifacts: LH.Artifacts, context: LH.Audit.Context): Promise<LH.Audit.Product>;
|
|
64
|
-
}
|
|
65
|
-
export namespace UIStrings {
|
|
66
|
-
let title: string;
|
|
67
|
-
let description: string;
|
|
68
|
-
let displayValue: string;
|
|
69
|
-
let columnProtocol: string;
|
|
70
|
-
}
|
|
71
|
-
import { Audit } from '../audit.js';
|
|
72
|
-
//# sourceMappingURL=uses-http2.d.ts.map
|