lighthouse 9.5.0-dev.20220607 → 9.6.2

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.
Files changed (262) hide show
  1. package/dist/report/bundle.esm.js +467 -520
  2. package/dist/report/flow.js +22 -22
  3. package/dist/report/standalone.js +19 -19
  4. package/flow-report/src/summary/category.tsx +1 -1
  5. package/flow-report/src/topbar.tsx +2 -10
  6. package/flow-report/src/util.ts +1 -1
  7. package/flow-report/test/topbar-test.tsx +8 -7
  8. package/jest.config.js +1 -1
  9. package/lighthouse-cli/.eslintrc.cjs +4 -3
  10. package/lighthouse-cli/bin.js +1 -0
  11. package/lighthouse-cli/cli-flags.js +4 -3
  12. package/lighthouse-cli/commands/commands.js +1 -0
  13. package/lighthouse-cli/commands/list-audits.js +1 -0
  14. package/lighthouse-cli/commands/list-locales.js +1 -0
  15. package/lighthouse-cli/commands/list-trace-categories.js +1 -0
  16. package/lighthouse-cli/index.js +1 -0
  17. package/lighthouse-cli/printer.js +1 -0
  18. package/lighthouse-cli/run.js +24 -9
  19. package/lighthouse-cli/sentry-prompt.js +1 -0
  20. package/lighthouse-cli/test/smokehouse/core-tests.js +1 -0
  21. package/lighthouse-cli/test/smokehouse/frontends/back-compat-util.js +1 -0
  22. package/lighthouse-cli/test/smokehouse/frontends/lib.js +1 -0
  23. package/lighthouse-cli/test/smokehouse/frontends/node.js +1 -0
  24. package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +1 -0
  25. package/lighthouse-cli/test/smokehouse/lib/child-process-error.js +1 -0
  26. package/lighthouse-cli/test/smokehouse/lib/concurrent-mapper.js +1 -0
  27. package/lighthouse-cli/test/smokehouse/lib/local-console.js +1 -0
  28. package/lighthouse-cli/test/smokehouse/lighthouse-runners/bundle.js +23 -109
  29. package/lighthouse-cli/test/smokehouse/lighthouse-runners/cli.js +3 -2
  30. package/lighthouse-cli/test/smokehouse/lighthouse-runners/devtools.js +19 -28
  31. package/lighthouse-cli/test/smokehouse/report-assert.js +4 -3
  32. package/lighthouse-cli/test/smokehouse/smokehouse.js +1 -1
  33. package/lighthouse-cli/test/smokehouse/version-check-test.js +3 -0
  34. package/lighthouse-cli/test/smokehouse/version-check.js +1 -0
  35. package/lighthouse-core/audits/accessibility/accesskeys.js +1 -1
  36. package/lighthouse-core/audits/accessibility/aria-allowed-attr.js +1 -1
  37. package/lighthouse-core/audits/accessibility/aria-command-name.js +1 -1
  38. package/lighthouse-core/audits/accessibility/aria-hidden-body.js +1 -1
  39. package/lighthouse-core/audits/accessibility/aria-hidden-focus.js +1 -1
  40. package/lighthouse-core/audits/accessibility/aria-input-field-name.js +1 -1
  41. package/lighthouse-core/audits/accessibility/aria-meter-name.js +1 -1
  42. package/lighthouse-core/audits/accessibility/aria-progressbar-name.js +1 -1
  43. package/lighthouse-core/audits/accessibility/aria-required-attr.js +1 -1
  44. package/lighthouse-core/audits/accessibility/aria-required-children.js +1 -1
  45. package/lighthouse-core/audits/accessibility/aria-required-parent.js +1 -1
  46. package/lighthouse-core/audits/accessibility/aria-roles.js +1 -1
  47. package/lighthouse-core/audits/accessibility/aria-toggle-field-name.js +1 -1
  48. package/lighthouse-core/audits/accessibility/aria-tooltip-name.js +1 -1
  49. package/lighthouse-core/audits/accessibility/aria-treeitem-name.js +1 -1
  50. package/lighthouse-core/audits/accessibility/aria-valid-attr-value.js +1 -1
  51. package/lighthouse-core/audits/accessibility/aria-valid-attr.js +1 -1
  52. package/lighthouse-core/audits/accessibility/button-name.js +1 -1
  53. package/lighthouse-core/audits/accessibility/bypass.js +1 -1
  54. package/lighthouse-core/audits/accessibility/color-contrast.js +1 -1
  55. package/lighthouse-core/audits/accessibility/definition-list.js +1 -1
  56. package/lighthouse-core/audits/accessibility/dlitem.js +1 -1
  57. package/lighthouse-core/audits/accessibility/document-title.js +1 -1
  58. package/lighthouse-core/audits/accessibility/duplicate-id-active.js +1 -1
  59. package/lighthouse-core/audits/accessibility/duplicate-id-aria.js +1 -1
  60. package/lighthouse-core/audits/accessibility/form-field-multiple-labels.js +1 -1
  61. package/lighthouse-core/audits/accessibility/frame-title.js +1 -1
  62. package/lighthouse-core/audits/accessibility/heading-order.js +1 -1
  63. package/lighthouse-core/audits/accessibility/html-has-lang.js +1 -1
  64. package/lighthouse-core/audits/accessibility/html-lang-valid.js +1 -1
  65. package/lighthouse-core/audits/accessibility/image-alt.js +1 -1
  66. package/lighthouse-core/audits/accessibility/input-image-alt.js +1 -1
  67. package/lighthouse-core/audits/accessibility/label.js +1 -1
  68. package/lighthouse-core/audits/accessibility/link-name.js +1 -1
  69. package/lighthouse-core/audits/accessibility/list.js +1 -1
  70. package/lighthouse-core/audits/accessibility/listitem.js +5 -5
  71. package/lighthouse-core/audits/accessibility/meta-refresh.js +1 -1
  72. package/lighthouse-core/audits/accessibility/meta-viewport.js +1 -1
  73. package/lighthouse-core/audits/accessibility/object-alt.js +1 -1
  74. package/lighthouse-core/audits/accessibility/tabindex.js +1 -1
  75. package/lighthouse-core/audits/accessibility/td-headers-attr.js +1 -1
  76. package/lighthouse-core/audits/accessibility/th-has-data-cells.js +1 -1
  77. package/lighthouse-core/audits/accessibility/valid-lang.js +1 -1
  78. package/lighthouse-core/audits/accessibility/video-caption.js +1 -1
  79. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +1 -2
  80. package/lighthouse-core/audits/byte-efficiency/duplicated-javascript.js +12 -11
  81. package/lighthouse-core/audits/byte-efficiency/efficient-animated-content.js +1 -1
  82. package/lighthouse-core/audits/byte-efficiency/legacy-javascript.js +24 -22
  83. package/lighthouse-core/audits/byte-efficiency/offscreen-images.js +2 -3
  84. package/lighthouse-core/audits/byte-efficiency/render-blocking-resources.js +3 -2
  85. package/lighthouse-core/audits/byte-efficiency/unminified-css.js +5 -3
  86. package/lighthouse-core/audits/byte-efficiency/unminified-javascript.js +11 -10
  87. package/lighthouse-core/audits/byte-efficiency/unused-css-rules.js +1 -0
  88. package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +8 -11
  89. package/lighthouse-core/audits/byte-efficiency/uses-responsive-images.js +1 -1
  90. package/lighthouse-core/audits/byte-efficiency/uses-text-compression.js +1 -1
  91. package/lighthouse-core/audits/deprecations.js +598 -8
  92. package/lighthouse-core/audits/diagnostics.js +3 -4
  93. package/lighthouse-core/audits/dobetterweb/doctype.js +9 -20
  94. package/lighthouse-core/audits/dobetterweb/geolocation-on-start.js +1 -1
  95. package/lighthouse-core/audits/dobetterweb/no-document-write.js +1 -1
  96. package/lighthouse-core/audits/dobetterweb/notification-on-start.js +1 -1
  97. package/lighthouse-core/audits/dobetterweb/uses-http2.js +1 -2
  98. package/lighthouse-core/audits/dobetterweb/uses-passive-event-listeners.js +1 -1
  99. package/lighthouse-core/audits/errors-in-console.js +2 -2
  100. package/lighthouse-core/audits/long-tasks.js +2 -3
  101. package/lighthouse-core/audits/metrics/first-contentful-paint-3g.js +2 -2
  102. package/lighthouse-core/audits/metrics/first-contentful-paint.js +2 -3
  103. package/lighthouse-core/audits/metrics/first-meaningful-paint.js +2 -3
  104. package/lighthouse-core/audits/metrics/interactive.js +2 -3
  105. package/lighthouse-core/audits/metrics/largest-contentful-paint.js +2 -3
  106. package/lighthouse-core/audits/metrics/max-potential-fid.js +2 -3
  107. package/lighthouse-core/audits/metrics/speed-index.js +2 -3
  108. package/lighthouse-core/audits/metrics/total-blocking-time.js +2 -3
  109. package/lighthouse-core/audits/metrics.js +2 -3
  110. package/lighthouse-core/audits/no-unload-listeners.js +15 -7
  111. package/lighthouse-core/audits/predictive-perf.js +1 -2
  112. package/lighthouse-core/audits/preload-lcp-image.js +3 -3
  113. package/lighthouse-core/audits/redirects.js +1 -1
  114. package/lighthouse-core/audits/script-treemap-data.js +45 -45
  115. package/lighthouse-core/audits/seo/http-status-code.js +4 -2
  116. package/lighthouse-core/audits/seo/link-text.js +0 -2
  117. package/lighthouse-core/audits/server-response-time.js +17 -2
  118. package/lighthouse-core/audits/service-worker.js +2 -7
  119. package/lighthouse-core/audits/timing-budget.js +2 -3
  120. package/lighthouse-core/audits/uses-rel-preconnect.js +1 -1
  121. package/lighthouse-core/audits/uses-rel-preload.js +1 -1
  122. package/lighthouse-core/audits/valid-source-maps.js +14 -12
  123. package/lighthouse-core/audits/violation-audit.js +1 -1
  124. package/lighthouse-core/audits/work-during-interaction.js +2 -2
  125. package/lighthouse-core/computed/critical-request-chains.js +9 -5
  126. package/lighthouse-core/computed/js-bundles.js +11 -11
  127. package/lighthouse-core/computed/main-resource.js +2 -3
  128. package/lighthouse-core/computed/metrics/first-contentful-paint-all-frames.js +1 -1
  129. package/lighthouse-core/computed/metrics/first-contentful-paint.js +1 -1
  130. package/lighthouse-core/computed/metrics/first-meaningful-paint.js +1 -1
  131. package/lighthouse-core/computed/metrics/interactive.js +1 -1
  132. package/lighthouse-core/computed/metrics/lantern-first-contentful-paint.js +1 -1
  133. package/lighthouse-core/computed/metrics/lantern-first-meaningful-paint.js +1 -1
  134. package/lighthouse-core/computed/metrics/lantern-interactive.js +1 -1
  135. package/lighthouse-core/computed/metrics/lantern-largest-contentful-paint.js +1 -1
  136. package/lighthouse-core/computed/metrics/lantern-max-potential-fid.js +1 -1
  137. package/lighthouse-core/computed/metrics/lantern-metric.js +5 -3
  138. package/lighthouse-core/computed/metrics/lantern-speed-index.js +1 -1
  139. package/lighthouse-core/computed/metrics/lantern-total-blocking-time.js +1 -1
  140. package/lighthouse-core/computed/metrics/largest-contentful-paint-all-frames.js +1 -1
  141. package/lighthouse-core/computed/metrics/largest-contentful-paint.js +1 -1
  142. package/lighthouse-core/computed/metrics/max-potential-fid.js +1 -1
  143. package/lighthouse-core/computed/metrics/metric.js +0 -1
  144. package/lighthouse-core/computed/metrics/speed-index.js +1 -1
  145. package/lighthouse-core/computed/metrics/timing-summary.js +6 -13
  146. package/lighthouse-core/computed/metrics/total-blocking-time.js +1 -1
  147. package/lighthouse-core/computed/module-duplication.js +5 -6
  148. package/lighthouse-core/computed/page-dependency-graph.js +28 -55
  149. package/lighthouse-core/computed/resource-summary.js +5 -5
  150. package/lighthouse-core/computed/unused-css.js +7 -6
  151. package/lighthouse-core/computed/unused-javascript-summary.js +36 -16
  152. package/lighthouse-core/config/budget.js +2 -2
  153. package/lighthouse-core/config/default-config.js +1 -2
  154. package/lighthouse-core/fraggle-rock/api.js +1 -1
  155. package/lighthouse-core/fraggle-rock/config/default-config.js +0 -3
  156. package/lighthouse-core/fraggle-rock/gather/base-artifacts.js +3 -6
  157. package/lighthouse-core/fraggle-rock/gather/driver.js +2 -2
  158. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +26 -51
  159. package/lighthouse-core/fraggle-rock/gather/runner-helpers.js +3 -0
  160. package/lighthouse-core/fraggle-rock/gather/session.js +22 -23
  161. package/lighthouse-core/fraggle-rock/gather/snapshot-runner.js +4 -5
  162. package/lighthouse-core/fraggle-rock/gather/timespan-runner.js +6 -6
  163. package/lighthouse-core/gather/connections/cri.js +1 -5
  164. package/lighthouse-core/gather/driver/execution-context.js +2 -5
  165. package/lighthouse-core/gather/driver/navigation.js +10 -13
  166. package/lighthouse-core/gather/driver/network-monitor.js +3 -16
  167. package/lighthouse-core/gather/driver.js +1 -6
  168. package/lighthouse-core/gather/fetcher.js +210 -34
  169. package/lighthouse-core/gather/gather-runner.js +17 -13
  170. package/lighthouse-core/gather/gatherers/accessibility.js +4 -16
  171. package/lighthouse-core/gather/gatherers/console-messages.js +2 -4
  172. package/lighthouse-core/gather/gatherers/dobetterweb/doctype.js +2 -4
  173. package/lighthouse-core/gather/gatherers/full-page-screenshot.js +2 -3
  174. package/lighthouse-core/gather/gatherers/iframe-elements.js +1 -4
  175. package/lighthouse-core/gather/gatherers/image-elements.js +0 -2
  176. package/lighthouse-core/gather/gatherers/js-usage.js +87 -12
  177. package/lighthouse-core/gather/gatherers/link-elements.js +14 -12
  178. package/lighthouse-core/gather/gatherers/main-document-content.js +8 -8
  179. package/lighthouse-core/gather/gatherers/script-elements.js +56 -7
  180. package/lighthouse-core/gather/gatherers/seo/robots-txt.js +30 -2
  181. package/lighthouse-core/gather/gatherers/source-maps.js +1 -8
  182. package/lighthouse-core/gather/gatherers/web-app-manifest.js +2 -2
  183. package/lighthouse-core/index.js +2 -26
  184. package/lighthouse-core/lib/cdt/generated/SourceMap.js +1 -1
  185. package/lighthouse-core/lib/dependency-graph/simulator/network-analyzer.js +29 -8
  186. package/lighthouse-core/lib/navigation-error.js +4 -13
  187. package/lighthouse-core/lib/page-functions.js +1 -3
  188. package/lighthouse-core/lib/script-helpers.js +6 -11
  189. package/lighthouse-core/lib/url-shim.js +2 -2
  190. package/lighthouse-core/runner.js +5 -0
  191. package/lighthouse-core/scripts/manual-chrome-launcher.js +1 -0
  192. package/lighthouse-core/util-commonjs.js +6 -8
  193. package/package.json +13 -13
  194. package/readme.md +1 -1
  195. package/report/.eslintrc.cjs +1 -3
  196. package/report/assets/styles.css +5 -10
  197. package/report/assets/templates.html +9 -10
  198. package/report/clients/bundle.js +1 -0
  199. package/report/clients/standalone.js +1 -0
  200. package/report/generator/report-generator.js +21 -46
  201. package/report/renderer/api.js +2 -0
  202. package/report/renderer/category-renderer.js +24 -20
  203. package/report/renderer/components.js +304 -303
  204. package/report/renderer/crc-details-renderer.js +24 -21
  205. package/report/renderer/details-renderer.js +12 -12
  206. package/report/renderer/dom.js +7 -6
  207. package/report/renderer/drop-down-menu.js +1 -0
  208. package/report/renderer/element-screenshot-renderer.js +5 -1
  209. package/report/renderer/features-util.js +1 -0
  210. package/report/renderer/i18n.js +62 -118
  211. package/report/renderer/logger.js +1 -0
  212. package/report/renderer/open-tab.js +3 -1
  213. package/report/renderer/performance-category-renderer.js +11 -10
  214. package/report/renderer/pwa-category-renderer.js +4 -3
  215. package/report/renderer/report-renderer.js +17 -17
  216. package/report/renderer/report-ui-features.js +1 -0
  217. package/report/renderer/snippet-renderer.js +3 -2
  218. package/report/renderer/swap-locale-feature.js +1 -0
  219. package/report/renderer/text-encoding.js +1 -0
  220. package/report/renderer/topbar-features.js +1 -0
  221. package/report/renderer/util.js +6 -7
  222. package/report/test/clients/bundle-test.js +5 -0
  223. package/report/test/generator/file-namer-test.js +1 -0
  224. package/report/test/generator/report-generator-test.js +20 -25
  225. package/report/test/renderer/category-renderer-test.js +4 -3
  226. package/report/test/renderer/components-test.js +3 -0
  227. package/report/test/renderer/crc-details-renderer-test.js +3 -0
  228. package/report/test/renderer/details-renderer-test.js +3 -49
  229. package/report/test/renderer/dom-test.js +3 -0
  230. package/report/test/renderer/element-screenshot-renderer-test.js +6 -3
  231. package/report/test/renderer/i18n-test.js +25 -70
  232. package/report/test/renderer/performance-category-renderer-test.js +5 -14
  233. package/report/test/renderer/pwa-category-renderer-test.js +4 -3
  234. package/report/test/renderer/report-renderer-axe-test.js +4 -3
  235. package/report/test/renderer/report-renderer-test.js +4 -3
  236. package/report/test/renderer/report-ui-features-test.js +4 -3
  237. package/report/test/renderer/snippet-renderer-test.js +3 -0
  238. package/report/test/renderer/text-encoding-test.js +3 -0
  239. package/report/test/renderer/util-test.js +5 -4
  240. package/report/test-assets/faux-psi.js +1 -2
  241. package/shared/localization/format.js +3 -7
  242. package/shared/localization/locales/en-US.json +238 -55
  243. package/shared/localization/locales/en-XL.json +238 -55
  244. package/shared/test/localization/format-test.js +2 -8
  245. package/shared/test/localization/locales-test.js +2 -0
  246. package/shared/test/localization/swap-locale-test.js +2 -0
  247. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +2 -0
  248. package/third-party/chromium-synchronization/installability-errors-test.js +2 -0
  249. package/tsconfig.json +0 -1
  250. package/types/artifacts.d.ts +8 -47
  251. package/types/config.d.ts +0 -2
  252. package/types/externs.d.ts +2 -3
  253. package/types/gatherer.d.ts +2 -1
  254. package/types/global-lh.d.ts +0 -3
  255. package/types/lhr/lhr.d.ts +2 -2
  256. package/types/lhr/treemap.d.ts +1 -0
  257. package/changelog.md +0 -5902
  258. package/lighthouse-core/audits/script-elements-test-audit.js +0 -30
  259. package/lighthouse-core/gather/gatherers/scripts.js +0 -154
  260. package/lighthouse-core/scripts/package.json +0 -4
  261. package/report/test/.eslintrc.cjs +0 -11
  262. package/shared/test/localization/.eslintrc.cjs +0 -11
@@ -21,7 +21,7 @@ const UIStrings = {
21
21
  /** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
22
22
  description: 'Screen readers cannot translate non-text content. Adding alternate text to ' +
23
23
  '`<object>` elements helps screen readers convey meaning to users. ' +
24
- '[Learn more](https://dequeuniversity.com/rules/axe/4.4/object-alt).',
24
+ '[Learn more](https://web.dev/object-alt/).',
25
25
  };
26
26
 
27
27
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -21,7 +21,7 @@ const UIStrings = {
21
21
  /** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
22
22
  description: 'A value greater than 0 implies an explicit navigation ordering. ' +
23
23
  'Although technically valid, this often creates frustrating experiences ' +
24
- 'for users who rely on assistive technologies. [Learn more](https://dequeuniversity.com/rules/axe/4.4/tabindex).',
24
+ 'for users who rely on assistive technologies. [Learn more](https://web.dev/tabindex/).',
25
25
  };
26
26
 
27
27
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -25,7 +25,7 @@ const UIStrings = {
25
25
  description: 'Screen readers have features to make navigating tables easier. Ensuring ' +
26
26
  '`<td>` cells using the `[headers]` attribute only refer to other cells in the same ' +
27
27
  'table may improve the experience for screen reader users. ' +
28
- '[Learn more](https://dequeuniversity.com/rules/axe/4.4/td-headers-attr).',
28
+ '[Learn more](https://web.dev/td-headers-attr/).',
29
29
  };
30
30
 
31
31
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -24,7 +24,7 @@ const UIStrings = {
24
24
  description: 'Screen readers have features to make navigating tables easier. Ensuring ' +
25
25
  'table headers always refer to some set of cells may improve the experience for screen ' +
26
26
  'reader users. ' +
27
- '[Learn more](https://dequeuniversity.com/rules/axe/4.4/th-has-data-cells).',
27
+ '[Learn more](https://web.dev/th-has-data-cells/).',
28
28
  };
29
29
 
30
30
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -21,7 +21,7 @@ const UIStrings = {
21
21
  /** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
22
22
  description: 'Specifying a valid [BCP 47 language](https://www.w3.org/International/questions/qa-choosing-language-tags#question) ' +
23
23
  'on elements helps ensure that text is pronounced correctly by a screen reader. ' +
24
- '[Learn more](https://dequeuniversity.com/rules/axe/4.4/valid-lang).',
24
+ '[Learn more](https://web.dev/valid-lang/).',
25
25
  };
26
26
 
27
27
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -22,7 +22,7 @@ const UIStrings = {
22
22
  /** Description of a Lighthouse audit that tells the user *why* they should try to pass. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
23
23
  description: 'When a video provides a caption it is easier for deaf and hearing impaired ' +
24
24
  'users to access its information. ' +
25
- '[Learn more](https://dequeuniversity.com/rules/axe/4.4/video-caption).',
25
+ '[Learn more](https://web.dev/video-caption/).',
26
26
  };
27
27
 
28
28
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -109,7 +109,6 @@ class UnusedBytes extends Audit {
109
109
  const gatherContext = artifacts.GatherContext;
110
110
  const trace = artifacts.traces[Audit.DEFAULT_PASS];
111
111
  const devtoolsLog = artifacts.devtoolsLogs[Audit.DEFAULT_PASS];
112
- const URL = artifacts.URL;
113
112
  const settings = context?.settings || {};
114
113
  const simulatorOptions = {
115
114
  devtoolsLog,
@@ -132,7 +131,7 @@ class UnusedBytes extends Audit {
132
131
  this.audit_(artifacts, networkRecords, context),
133
132
  // Page dependency graph is only used in navigation mode.
134
133
  gatherContext.gatherMode === 'navigation' ?
135
- PageDependencyGraph.request({trace, devtoolsLog, URL}, context) :
134
+ PageDependencyGraph.request({trace, devtoolsLog}, context) :
136
135
  null,
137
136
  LoadSimulator.request(simulatorOptions, context),
138
137
  ]);
@@ -48,7 +48,7 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
48
48
  title: str_(UIStrings.title),
49
49
  description: str_(UIStrings.description),
50
50
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
51
- requiredArtifacts: ['devtoolsLogs', 'traces', 'SourceMaps', 'Scripts',
51
+ requiredArtifacts: ['devtoolsLogs', 'traces', 'SourceMaps', 'ScriptElements',
52
52
  'GatherContext', 'URL'],
53
53
  };
54
54
  }
@@ -85,10 +85,10 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
85
85
 
86
86
  const normalizedSource = 'node_modules/' + DuplicatedJavascript._getNodeModuleName(source);
87
87
  const aggregatedSourceDatas = groupedDuplication.get(normalizedSource) || [];
88
- for (const {scriptId, scriptUrl, resourceSize} of sourceDatas) {
89
- let sourceData = aggregatedSourceDatas.find(d => d.scriptId === scriptId);
88
+ for (const {scriptUrl, resourceSize} of sourceDatas) {
89
+ let sourceData = aggregatedSourceDatas.find(d => d.scriptUrl === scriptUrl);
90
90
  if (!sourceData) {
91
- sourceData = {scriptId, scriptUrl, resourceSize: 0};
91
+ sourceData = {scriptUrl, resourceSize: 0};
92
92
  aggregatedSourceDatas.push(sourceData);
93
93
  }
94
94
  sourceData.resourceSize += resourceSize;
@@ -156,20 +156,21 @@ class DuplicatedJavascript extends ByteEfficiencyAudit {
156
156
  let wastedBytesTotal = 0;
157
157
  for (let i = 0; i < sourceDatas.length; i++) {
158
158
  const sourceData = sourceDatas[i];
159
- const scriptId = sourceData.scriptId;
160
- const script = artifacts.Scripts.find(script => script.scriptId === scriptId);
161
- const url = script?.url || '';
159
+ const url = sourceData.scriptUrl;
162
160
 
163
161
  /** @type {number|undefined} */
164
162
  let transferRatio = transferRatioByUrl.get(url);
165
163
  if (transferRatio === undefined) {
166
- if (!script || script.length === undefined) {
167
- // This should never happen because we found the wasted bytes from bundles, which required contents in a Script.
164
+ const fakeScript = /** @type {LH.Artifacts.ScriptElement} */ ({src: url});
165
+ const networkRecord = getRequestForScript(networkRecords, fakeScript);
166
+
167
+ const script = artifacts.ScriptElements.find(script => script.src === url);
168
+ if (!script || script.content === null) {
169
+ // This should never happen because we found the wasted bytes from bundles, which required contents in a ScriptElement.
168
170
  continue;
169
171
  }
170
172
 
171
- const contentLength = script.length;
172
- const networkRecord = getRequestForScript(networkRecords, script);
173
+ const contentLength = script.content.length;
173
174
  transferRatio = DuplicatedJavascript._estimateTransferRatio(networkRecord, contentLength);
174
175
  transferRatioByUrl.set(url, transferRatio);
175
176
  }
@@ -37,7 +37,7 @@ class EfficientAnimatedContent extends ByteEfficiencyAudit {
37
37
  title: str_(UIStrings.title),
38
38
  description: str_(UIStrings.description),
39
39
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
40
- requiredArtifacts: ['devtoolsLogs', 'traces', 'GatherContext', 'URL'],
40
+ requiredArtifacts: ['devtoolsLogs', 'traces', 'GatherContext'],
41
41
  };
42
42
  }
43
43
 
@@ -30,7 +30,7 @@ const UIStrings = {
30
30
  // eslint-disable-next-line max-len
31
31
  // TODO: web.dev article. this codelab is good starting place: https://web.dev/codelab-serve-modern-code/
32
32
  /** Description of a Lighthouse audit that tells the user about old JavaScript that is no longer needed. This is displayed after a user expands the section to see more. No character length limits. 'Learn More' becomes link text to additional documentation. */
33
- description: 'Polyfills and transforms enable legacy browsers to use new JavaScript features. However, many aren\'t necessary for modern browsers. For your bundled JavaScript, adopt a modern script deployment strategy using module/nomodule feature detection to reduce the amount of code shipped to modern browsers, while retaining support for legacy browsers. [Learn More](https://web.dev/publish-modern-javascript/)',
33
+ description: 'Polyfills and transforms enable legacy browsers to use new JavaScript features. However, many aren\'t necessary for modern browsers. For your bundled JavaScript, adopt a modern script deployment strategy using module/nomodule feature detection to reduce the amount of code shipped to modern browsers, while retaining support for legacy browsers. [Learn More](https://philipwalton.com/articles/deploying-es2015-code-in-production-today/)',
34
34
  };
35
35
 
36
36
  const str_ = i18n.createMessageInstanceIdFn(__filename, UIStrings);
@@ -109,7 +109,7 @@ class LegacyJavascript extends ByteEfficiencyAudit {
109
109
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
110
110
  description: str_(UIStrings.description),
111
111
  title: str_(UIStrings.title),
112
- requiredArtifacts: ['devtoolsLogs', 'traces', 'Scripts', 'SourceMaps',
112
+ requiredArtifacts: ['devtoolsLogs', 'traces', 'ScriptElements', 'SourceMaps',
113
113
  'GatherContext', 'URL'],
114
114
  };
115
115
  }
@@ -274,24 +274,26 @@ class LegacyJavascript extends ByteEfficiencyAudit {
274
274
  * Returns a collection of match results grouped by script url.
275
275
  *
276
276
  * @param {CodePatternMatcher} matcher
277
- * @param {LH.Artifacts['Scripts']} scripts
277
+ * @param {LH.GathererArtifacts['ScriptElements']} scripts
278
278
  * @param {LH.Artifacts.NetworkRequest[]} networkRecords
279
279
  * @param {LH.Artifacts.Bundle[]} bundles
280
- * @return {Map<LH.Artifacts.Script, PatternMatchResult[]>}
280
+ * @return {Map<string, PatternMatchResult[]>}
281
281
  */
282
282
  static detectAcrossScripts(matcher, scripts, networkRecords, bundles) {
283
- /** @type {Map<LH.Artifacts.Script, PatternMatchResult[]>} */
284
- const scriptToMatchResults = new Map();
283
+ /** @type {Map<string, PatternMatchResult[]>} */
284
+ const urlToMatchResults = new Map();
285
285
  const polyfillData = this.getPolyfillData();
286
286
 
287
- for (const script of Object.values(scripts)) {
288
- if (!script.content) continue;
287
+ for (const {requestId, content} of Object.values(scripts)) {
288
+ if (!content) continue;
289
+ const networkRecord = networkRecords.find(record => record.requestId === requestId);
290
+ if (!networkRecord) continue;
289
291
 
290
292
  // Start with pattern matching against the downloaded script.
291
- const matches = matcher.match(script.content);
293
+ const matches = matcher.match(content);
292
294
 
293
295
  // If it's a bundle with source maps, add in the polyfill modules by name too.
294
- const bundle = bundles.find(b => b.script.scriptId === script.scriptId);
296
+ const bundle = bundles.find(b => b.script.src === networkRecord.url);
295
297
  if (bundle) {
296
298
  for (const {coreJs2Module, coreJs3Module, name} of polyfillData) {
297
299
  // Skip if the pattern matching found a match for this polyfill.
@@ -311,10 +313,10 @@ class LegacyJavascript extends ByteEfficiencyAudit {
311
313
  }
312
314
 
313
315
  if (!matches.length) continue;
314
- scriptToMatchResults.set(script, matches);
316
+ urlToMatchResults.set(networkRecord.url, matches);
315
317
  }
316
318
 
317
- return scriptToMatchResults;
319
+ return urlToMatchResults;
318
320
  }
319
321
 
320
322
  /**
@@ -371,14 +373,14 @@ class LegacyJavascript extends ByteEfficiencyAudit {
371
373
  let transferRatio = transferRatioByUrl.get(url);
372
374
  if (transferRatio !== undefined) return transferRatio;
373
375
 
374
- const script = artifacts.Scripts.find(script => script.url === url);
376
+ const script = artifacts.ScriptElements.find(script => script.src === url);
377
+ const networkRecord = getRequestForScript(networkRecords, script);
375
378
 
376
379
  if (!script || script.content === null) {
377
380
  // Can't find content, so just use 1.
378
381
  transferRatio = 1;
379
382
  } else {
380
- const networkRecord = getRequestForScript(networkRecords, script);
381
- const contentLength = script.length || 0;
383
+ const contentLength = script.content.length;
382
384
  const transferSize =
383
385
  ByteEfficiencyAudit.estimateTransferSize(networkRecord, contentLength, 'Script');
384
386
  transferRatio = transferSize / contentLength;
@@ -409,15 +411,15 @@ class LegacyJavascript extends ByteEfficiencyAudit {
409
411
  /** @type {Map<string, number>} */
410
412
  const transferRatioByUrl = new Map();
411
413
 
412
- const scriptToMatchResults =
413
- this.detectAcrossScripts(matcher, artifacts.Scripts, networkRecords, bundles);
414
- for (const [script, matches] of scriptToMatchResults.entries()) {
414
+ const urlToMatchResults =
415
+ this.detectAcrossScripts(matcher, artifacts.ScriptElements, networkRecords, bundles);
416
+ for (const [url, matches] of urlToMatchResults.entries()) {
415
417
  const transferRatio = await this.estimateTransferRatioForScript(
416
- transferRatioByUrl, script.url, artifacts, networkRecords);
418
+ transferRatioByUrl, url, artifacts, networkRecords);
417
419
  const wastedBytes = Math.round(this.estimateWastedBytes(matches) * transferRatio);
418
420
  /** @type {typeof items[number]} */
419
421
  const item = {
420
- url: script.url,
422
+ url,
421
423
  wastedBytes,
422
424
  subItems: {
423
425
  type: 'subitems',
@@ -427,13 +429,13 @@ class LegacyJavascript extends ByteEfficiencyAudit {
427
429
  totalBytes: 0,
428
430
  };
429
431
 
430
- const bundle = bundles.find(bundle => bundle.script.scriptId === script.scriptId);
432
+ const bundle = bundles.find(bundle => bundle.script.src === url);
431
433
  for (const match of matches) {
432
434
  const {name, line, column} = match;
433
435
  /** @type {SubItem} */
434
436
  const subItem = {
435
437
  signal: name,
436
- location: ByteEfficiencyAudit.makeSourceLocation(script.url, line, column, bundle),
438
+ location: ByteEfficiencyAudit.makeSourceLocation(url, line, column, bundle),
437
439
  };
438
440
  item.subItems.items.push(subItem);
439
441
  }
@@ -51,7 +51,7 @@ class OffscreenImages extends ByteEfficiencyAudit {
51
51
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
52
52
  supportedModes: ['navigation'],
53
53
  requiredArtifacts: ['ImageElements', 'ViewportDimensions', 'GatherContext', 'devtoolsLogs',
54
- 'traces', 'URL'],
54
+ 'traces'],
55
55
  };
56
56
  }
57
57
 
@@ -182,7 +182,6 @@ class OffscreenImages extends ByteEfficiencyAudit {
182
182
  const gatherContext = artifacts.GatherContext;
183
183
  const trace = artifacts.traces[ByteEfficiencyAudit.DEFAULT_PASS];
184
184
  const devtoolsLog = artifacts.devtoolsLogs[ByteEfficiencyAudit.DEFAULT_PASS];
185
- const URL = artifacts.URL;
186
185
 
187
186
  /** @type {string[]} */
188
187
  const warnings = [];
@@ -213,7 +212,7 @@ class OffscreenImages extends ByteEfficiencyAudit {
213
212
  const unfilteredResults = Array.from(resultsMap.values());
214
213
  // get the interactive time or fallback to getting the end of trace time
215
214
  try {
216
- const metricComputationData = {trace, devtoolsLog, gatherContext, settings, URL};
215
+ const metricComputationData = {trace, devtoolsLog, gatherContext, settings};
217
216
  const interactive = await Interactive.request(metricComputationData, context);
218
217
 
219
218
  // use interactive to generate items
@@ -145,7 +145,7 @@ class RenderBlockingResources extends Audit {
145
145
  };
146
146
 
147
147
  const metricComputationData = {trace, devtoolsLog, gatherContext, simulator,
148
- settings: metricSettings, URL: artifacts.URL};
148
+ settings: metricSettings};
149
149
 
150
150
  // Cast to just `LanternMetric` since we explicitly set `throttlingMethod: 'simulate'`.
151
151
  const fcpSimulation = /** @type {LH.Artifacts.LanternMetric} */
@@ -262,12 +262,13 @@ class RenderBlockingResources extends Audit {
262
262
  try {
263
263
  const unusedCssItems = await UnusedCSS.request({
264
264
  CSSUsage: artifacts.CSSUsage,
265
+ URL: artifacts.URL,
265
266
  devtoolsLog: artifacts.devtoolsLogs[Audit.DEFAULT_PASS],
266
267
  }, context);
267
268
  for (const item of unusedCssItems) {
268
269
  wastedBytesByUrl.set(item.url, item.wastedBytes);
269
270
  }
270
- } catch {}
271
+ } catch (_) {}
271
272
 
272
273
  return wastedBytesByUrl;
273
274
  }
@@ -53,14 +53,15 @@ class UnminifiedCSS extends ByteEfficiencyAudit {
53
53
  /**
54
54
  * @param {LH.Artifacts.CSSStyleSheetInfo} stylesheet
55
55
  * @param {LH.Artifacts.NetworkRequest|undefined} networkRecord
56
+ * @param {string} pageUrl
56
57
  * @return {{url: string, totalBytes: number, wastedBytes: number, wastedPercent: number}}
57
58
  */
58
- static computeWaste(stylesheet, networkRecord) {
59
+ static computeWaste(stylesheet, networkRecord, pageUrl) {
59
60
  const content = stylesheet.content;
60
61
  const totalTokenLength = UnminifiedCSS.computeTokenLength(content);
61
62
 
62
63
  let url = stylesheet.header.sourceURL;
63
- if (!url || stylesheet.header.isInline) {
64
+ if (!url || url === pageUrl) {
64
65
  const contentPreview = UnusedCSS.determineContentPreview(stylesheet.content);
65
66
  url = contentPreview;
66
67
  }
@@ -84,13 +85,14 @@ class UnminifiedCSS extends ByteEfficiencyAudit {
84
85
  * @return {ByteEfficiencyAudit.ByteEfficiencyProduct}
85
86
  */
86
87
  static audit_(artifacts, networkRecords) {
88
+ const pageUrl = artifacts.URL.finalUrl;
87
89
  const items = [];
88
90
  for (const stylesheet of artifacts.CSSUsage.stylesheets) {
89
91
  const networkRecord = networkRecords
90
92
  .find(record => record.url === stylesheet.header.sourceURL);
91
93
  if (!stylesheet.content) continue;
92
94
 
93
- const result = UnminifiedCSS.computeWaste(stylesheet, networkRecord);
95
+ const result = UnminifiedCSS.computeWaste(stylesheet, networkRecord, pageUrl);
94
96
 
95
97
  // If the ratio is minimal, the file is likely already minified, so ignore it.
96
98
  // If the total number of bytes to be saved is quite small, it's also safe to ignore.
@@ -8,7 +8,7 @@
8
8
  const ByteEfficiencyAudit = require('./byte-efficiency-audit.js');
9
9
  const i18n = require('../../lib/i18n/i18n.js');
10
10
  const computeTokenLength = require('../../lib/minification-estimator.js').computeJSTokenLength;
11
- const {getRequestForScript, isInline} = require('../../lib/script-helpers.js');
11
+ const {getRequestForScript} = require('../../lib/script-helpers.js');
12
12
 
13
13
  const UIStrings = {
14
14
  /** Imperative title of a Lighthouse audit that tells the user to minify the page’s JS code to reduce file size. This is displayed in a list of audit titles that Lighthouse generates. */
@@ -43,7 +43,7 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
43
43
  title: str_(UIStrings.title),
44
44
  description: str_(UIStrings.description),
45
45
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
46
- requiredArtifacts: ['Scripts', 'devtoolsLogs', 'traces', 'GatherContext', 'URL'],
46
+ requiredArtifacts: ['ScriptElements', 'devtoolsLogs', 'traces', 'GatherContext'],
47
47
  };
48
48
  }
49
49
 
@@ -79,16 +79,16 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
79
79
  /** @type {Array<LH.Audit.ByteEfficiencyItem>} */
80
80
  const items = [];
81
81
  const warnings = [];
82
- for (const script of artifacts.Scripts) {
83
- if (!script.content) continue;
82
+ for (const script of artifacts.ScriptElements) {
83
+ const {src, content} = script;
84
+ if (!content) continue;
84
85
 
85
86
  const networkRecord = getRequestForScript(networkRecords, script);
86
-
87
- const displayUrl = isInline(script) ?
88
- `inline: ${script.content.substring(0, 40)}...` :
89
- script.url;
87
+ const displayUrl = !src || !networkRecord ?
88
+ `inline: ${content.substr(0, 40)}...` :
89
+ networkRecord.url;
90
90
  try {
91
- const result = UnminifiedJavaScript.computeWaste(script.content, displayUrl, networkRecord);
91
+ const result = UnminifiedJavaScript.computeWaste(content, displayUrl, networkRecord);
92
92
  // If the ratio is minimal, the file is likely already minified, so ignore it.
93
93
  // If the total number of bytes to be saved is quite small, it's also safe to ignore.
94
94
  if (result.wastedPercent < IGNORE_THRESHOLD_IN_PERCENT ||
@@ -96,7 +96,8 @@ class UnminifiedJavaScript extends ByteEfficiencyAudit {
96
96
  !Number.isFinite(result.wastedBytes)) continue;
97
97
  items.push(result);
98
98
  } catch (err) {
99
- warnings.push(`Unable to process script ${script.url}: ${err.message}`);
99
+ const url = networkRecord ? networkRecord.url : '?';
100
+ warnings.push(`Unable to process script ${url}: ${err.message}`);
100
101
  }
101
102
  }
102
103
 
@@ -47,6 +47,7 @@ class UnusedCSSRules extends ByteEfficiencyAudit {
47
47
  static async audit_(artifacts, _, context) {
48
48
  const unusedCssItems = await UnusedCSS.request({
49
49
  CSSUsage: artifacts.CSSUsage,
50
+ URL: artifacts.URL,
50
51
  devtoolsLog: artifacts.devtoolsLogs[ByteEfficiencyAudit.DEFAULT_PASS],
51
52
  }, context);
52
53
  const items = unusedCssItems
@@ -68,8 +68,8 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
68
68
  title: str_(UIStrings.title),
69
69
  description: str_(UIStrings.description),
70
70
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
71
- requiredArtifacts: ['JsUsage', 'Scripts', 'SourceMaps', 'GatherContext',
72
- 'devtoolsLogs', 'traces', 'URL'],
71
+ requiredArtifacts: ['JsUsage', 'ScriptElements', 'SourceMaps', 'GatherContext',
72
+ 'devtoolsLogs', 'traces'],
73
73
  };
74
74
  }
75
75
 
@@ -87,16 +87,13 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
87
87
  } = context.options || {};
88
88
 
89
89
  const items = [];
90
- for (const [scriptId, scriptCoverage] of Object.entries(artifacts.JsUsage)) {
91
- const script = artifacts.Scripts.find(s => s.scriptId === scriptId);
92
- if (!script) continue; // This should never happen.
93
-
94
- const networkRecord = getRequestForScript(networkRecords, script);
90
+ for (const [url, scriptCoverages] of Object.entries(artifacts.JsUsage)) {
91
+ const fakeScript = /** @type {LH.Artifacts.ScriptElement} */ ({src: url});
92
+ const networkRecord = getRequestForScript(networkRecords, fakeScript);
95
93
  if (!networkRecord) continue;
96
-
97
- const bundle = bundles.find(b => b.script.scriptId === scriptId);
94
+ const bundle = bundles.find(b => b.script.src === url);
98
95
  const unusedJsSummary =
99
- await UnusedJavaScriptSummary.request({scriptId, scriptCoverage, bundle}, context);
96
+ await UnusedJavaScriptSummary.request({url, scriptCoverages, bundle}, context);
100
97
  if (unusedJsSummary.wastedBytes === 0 || unusedJsSummary.totalBytes === 0) continue;
101
98
 
102
99
  const transfer = ByteEfficiencyAudit
@@ -104,7 +101,7 @@ class UnusedJavaScript extends ByteEfficiencyAudit {
104
101
  const transferRatio = transfer / unusedJsSummary.totalBytes;
105
102
  /** @type {LH.Audit.ByteEfficiencyItem} */
106
103
  const item = {
107
- url: script.url,
104
+ url: unusedJsSummary.url,
108
105
  totalBytes: Math.round(transferRatio * unusedJsSummary.totalBytes),
109
106
  wastedBytes: Math.round(transferRatio * unusedJsSummary.wastedBytes),
110
107
  wastedPercent: unusedJsSummary.wastedPercent,
@@ -44,7 +44,7 @@ class UsesResponsiveImages extends ByteEfficiencyAudit {
44
44
  description: str_(UIStrings.description),
45
45
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
46
46
  requiredArtifacts: ['ImageElements', 'ViewportDimensions', 'GatherContext',
47
- 'devtoolsLogs', 'traces', 'URL'],
47
+ 'devtoolsLogs', 'traces'],
48
48
  };
49
49
  }
50
50
 
@@ -37,7 +37,7 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit {
37
37
  title: str_(UIStrings.title),
38
38
  description: str_(UIStrings.description),
39
39
  scoreDisplayMode: ByteEfficiencyAudit.SCORING_MODES.NUMERIC,
40
- requiredArtifacts: ['ResponseCompression', 'GatherContext', 'devtoolsLogs', 'traces', 'URL'],
40
+ requiredArtifacts: ['ResponseCompression', 'GatherContext', 'devtoolsLogs', 'traces'],
41
41
  };
42
42
  }
43
43