@paulirish/trace_engine 0.0.56 → 0.0.58

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 (305) hide show
  1. package/.tmp/tsbuildinfo/tsconfig.tsbuildinfo +1 -1
  2. package/README.md +2 -2
  3. package/core/platform/Brand.d.ts +8 -1
  4. package/core/platform/Brand.js.map +1 -1
  5. package/core/platform/DevToolsPath.d.ts +1 -1
  6. package/core/platform/DevToolsPath.js +1 -1
  7. package/core/platform/DevToolsPath.js.map +1 -1
  8. package/core/platform/StringUtilities.d.ts +12 -2
  9. package/core/platform/StringUtilities.js +31 -7
  10. package/core/platform/StringUtilities.js.map +1 -1
  11. package/generated/protocol.d.ts +8290 -7994
  12. package/locales/af.json +82 -67
  13. package/locales/am.json +82 -67
  14. package/locales/ar.json +93 -78
  15. package/locales/as.json +82 -67
  16. package/locales/az.json +82 -67
  17. package/locales/be.json +81 -66
  18. package/locales/bg.json +82 -67
  19. package/locales/bn.json +82 -67
  20. package/locales/bs.json +82 -67
  21. package/locales/ca.json +82 -67
  22. package/locales/cs.json +82 -67
  23. package/locales/cy.json +82 -67
  24. package/locales/da.json +82 -67
  25. package/locales/de.json +82 -67
  26. package/locales/el.json +82 -67
  27. package/locales/en-GB.json +82 -67
  28. package/locales/en-US.json +13 -10
  29. package/locales/en-XL.json +13 -10
  30. package/locales/es-419.json +82 -67
  31. package/locales/es.json +82 -67
  32. package/locales/et.json +82 -67
  33. package/locales/eu.json +82 -67
  34. package/locales/fa.json +86 -71
  35. package/locales/fi.json +82 -67
  36. package/locales/fil.json +82 -67
  37. package/locales/fr-CA.json +82 -67
  38. package/locales/fr.json +82 -67
  39. package/locales/gl.json +82 -67
  40. package/locales/gu.json +82 -67
  41. package/locales/he.json +104 -89
  42. package/locales/hi.json +82 -67
  43. package/locales/hr.json +82 -67
  44. package/locales/hu.json +82 -67
  45. package/locales/hy.json +82 -67
  46. package/locales/id.json +82 -67
  47. package/locales/is.json +82 -67
  48. package/locales/it.json +82 -67
  49. package/locales/ja.json +82 -67
  50. package/locales/ka.json +82 -67
  51. package/locales/kk.json +82 -67
  52. package/locales/km.json +82 -67
  53. package/locales/kn.json +81 -66
  54. package/locales/ko.json +82 -67
  55. package/locales/ky.json +81 -66
  56. package/locales/lo.json +82 -67
  57. package/locales/lt.json +82 -67
  58. package/locales/lv.json +82 -67
  59. package/locales/mk.json +82 -67
  60. package/locales/ml.json +82 -67
  61. package/locales/mn.json +82 -67
  62. package/locales/mr.json +81 -66
  63. package/locales/ms.json +81 -66
  64. package/locales/my.json +83 -68
  65. package/locales/ne.json +83 -68
  66. package/locales/nl.json +82 -67
  67. package/locales/no.json +82 -67
  68. package/locales/or.json +82 -67
  69. package/locales/pa.json +81 -66
  70. package/locales/pl.json +82 -67
  71. package/locales/pt-PT.json +82 -67
  72. package/locales/pt.json +82 -67
  73. package/locales/ro.json +82 -67
  74. package/locales/ru.json +82 -67
  75. package/locales/si.json +82 -67
  76. package/locales/sk.json +82 -67
  77. package/locales/sl.json +82 -67
  78. package/locales/sq.json +82 -67
  79. package/locales/sr-Latn.json +82 -67
  80. package/locales/sr.json +82 -67
  81. package/locales/sv.json +82 -67
  82. package/locales/sw.json +81 -66
  83. package/locales/ta.json +82 -67
  84. package/locales/te.json +82 -67
  85. package/locales/th.json +84 -69
  86. package/locales/tr.json +81 -66
  87. package/locales/uk.json +81 -66
  88. package/locales/ur.json +82 -67
  89. package/locales/uz.json +81 -66
  90. package/locales/vi.json +82 -67
  91. package/locales/zh-HK.json +82 -67
  92. package/locales/zh-TW.json +82 -67
  93. package/locales/zh.json +82 -67
  94. package/locales/zu.json +82 -67
  95. package/models/trace/ModelImpl.d.ts +1 -1
  96. package/models/trace/ModelImpl.js +17 -7
  97. package/models/trace/ModelImpl.js.map +1 -1
  98. package/models/trace/Processor.js +26 -16
  99. package/models/trace/Processor.js.map +1 -1
  100. package/models/trace/extras/ThirdParties.js +1 -2
  101. package/models/trace/extras/ThirdParties.js.map +1 -1
  102. package/models/trace/extras/TraceTree.d.ts +4 -2
  103. package/models/trace/extras/TraceTree.js +7 -5
  104. package/models/trace/extras/TraceTree.js.map +1 -1
  105. package/models/trace/handlers/AnimationFramesHandler.d.ts +1 -0
  106. package/models/trace/handlers/AnimationFramesHandler.js +8 -0
  107. package/models/trace/handlers/AnimationFramesHandler.js.map +1 -1
  108. package/models/trace/handlers/ExtensionTraceDataHandler.d.ts +1 -1
  109. package/models/trace/handlers/ExtensionTraceDataHandler.js +29 -15
  110. package/models/trace/handlers/ExtensionTraceDataHandler.js.map +1 -1
  111. package/models/trace/handlers/FramesHandler.js +38 -28
  112. package/models/trace/handlers/FramesHandler.js.map +1 -1
  113. package/models/trace/handlers/ImagePaintingHandler.d.ts +2 -1
  114. package/models/trace/handlers/ImagePaintingHandler.js.map +1 -1
  115. package/models/trace/handlers/InitiatorsHandler.js +27 -0
  116. package/models/trace/handlers/InitiatorsHandler.js.map +1 -1
  117. package/models/trace/handlers/NetworkRequestsHandler.js +12 -2
  118. package/models/trace/handlers/NetworkRequestsHandler.js.map +1 -1
  119. package/models/trace/handlers/RendererHandler.d.ts +0 -5
  120. package/models/trace/handlers/RendererHandler.js +9 -12
  121. package/models/trace/handlers/RendererHandler.js.map +1 -1
  122. package/models/trace/handlers/SamplesHandler.js +6 -12
  123. package/models/trace/handlers/SamplesHandler.js.map +1 -1
  124. package/models/trace/handlers/ScriptsHandler.d.ts +4 -3
  125. package/models/trace/handlers/ScriptsHandler.js +3 -0
  126. package/models/trace/handlers/ScriptsHandler.js.map +1 -1
  127. package/models/trace/handlers/SelectorStatsHandler.d.ts +17 -0
  128. package/models/trace/handlers/SelectorStatsHandler.js +42 -0
  129. package/models/trace/handlers/SelectorStatsHandler.js.map +1 -1
  130. package/models/trace/handlers/UserInteractionsHandler.d.ts +4 -2
  131. package/models/trace/handlers/UserInteractionsHandler.js.map +1 -1
  132. package/models/trace/handlers/helpers.d.ts +3 -6
  133. package/models/trace/handlers/helpers.js +17 -9
  134. package/models/trace/handlers/helpers.js.map +1 -1
  135. package/models/trace/handlers/types.d.ts +4 -1
  136. package/models/trace/handlers/types.js.map +1 -1
  137. package/models/trace/helpers/SamplesIntegrator.d.ts +1 -0
  138. package/models/trace/helpers/SamplesIntegrator.js +21 -21
  139. package/models/trace/helpers/SamplesIntegrator.js.map +1 -1
  140. package/models/trace/helpers/SyntheticEvents.d.ts +0 -6
  141. package/models/trace/helpers/SyntheticEvents.js +2 -2
  142. package/models/trace/helpers/SyntheticEvents.js.map +1 -1
  143. package/models/trace/helpers/Timing.d.ts +5 -0
  144. package/models/trace/helpers/Timing.js +55 -3
  145. package/models/trace/helpers/Timing.js.map +1 -1
  146. package/models/trace/helpers/Trace.d.ts +1 -1
  147. package/models/trace/helpers/Trace.js +1 -1
  148. package/models/trace/helpers/Trace.js.map +1 -1
  149. package/models/trace/helpers/TreeHelpers.d.ts +1 -1
  150. package/models/trace/helpers/TreeHelpers.js.map +1 -1
  151. package/models/trace/insights/CLSCulprits.d.ts +3 -2
  152. package/models/trace/insights/CLSCulprits.js +24 -2
  153. package/models/trace/insights/CLSCulprits.js.map +1 -1
  154. package/models/trace/insights/Cache.d.ts +2 -0
  155. package/models/trace/insights/Cache.js +10 -0
  156. package/models/trace/insights/Cache.js.map +1 -1
  157. package/models/trace/insights/Common.d.ts +6 -5
  158. package/models/trace/insights/Common.js +29 -17
  159. package/models/trace/insights/Common.js.map +1 -1
  160. package/models/trace/insights/DOMSize.d.ts +2 -1
  161. package/models/trace/insights/DOMSize.js +9 -1
  162. package/models/trace/insights/DOMSize.js.map +1 -1
  163. package/models/trace/insights/DocumentLatency.d.ts +3 -2
  164. package/models/trace/insights/DocumentLatency.js +44 -2
  165. package/models/trace/insights/DocumentLatency.js.map +1 -1
  166. package/models/trace/insights/DuplicatedJavaScript.d.ts +3 -0
  167. package/models/trace/insights/DuplicatedJavaScript.js +12 -3
  168. package/models/trace/insights/DuplicatedJavaScript.js.map +1 -1
  169. package/models/trace/insights/FontDisplay.d.ts +1 -0
  170. package/models/trace/insights/FontDisplay.js +7 -0
  171. package/models/trace/insights/FontDisplay.js.map +1 -1
  172. package/models/trace/insights/ForcedReflow.d.ts +5 -3
  173. package/models/trace/insights/ForcedReflow.js +20 -3
  174. package/models/trace/insights/ForcedReflow.js.map +1 -1
  175. package/models/trace/insights/INPBreakdown.d.ts +11 -5
  176. package/models/trace/insights/INPBreakdown.js +36 -5
  177. package/models/trace/insights/INPBreakdown.js.map +1 -1
  178. package/models/trace/insights/ImageDelivery.d.ts +4 -0
  179. package/models/trace/insights/ImageDelivery.js +13 -0
  180. package/models/trace/insights/ImageDelivery.js.map +1 -1
  181. package/models/trace/insights/LCPBreakdown.d.ts +7 -6
  182. package/models/trace/insights/LCPBreakdown.js +33 -12
  183. package/models/trace/insights/LCPBreakdown.js.map +1 -1
  184. package/models/trace/insights/LCPDiscovery.d.ts +14 -2
  185. package/models/trace/insights/LCPDiscovery.js +60 -2
  186. package/models/trace/insights/LCPDiscovery.js.map +1 -1
  187. package/models/trace/insights/LegacyJavaScript.d.ts +3 -0
  188. package/models/trace/insights/LegacyJavaScript.js +12 -3
  189. package/models/trace/insights/LegacyJavaScript.js.map +1 -1
  190. package/models/trace/insights/ModernHTTP.d.ts +8 -5
  191. package/models/trace/insights/ModernHTTP.js +27 -14
  192. package/models/trace/insights/ModernHTTP.js.map +1 -1
  193. package/models/trace/insights/NetworkDependencyTree.d.ts +1 -0
  194. package/models/trace/insights/NetworkDependencyTree.js +25 -1
  195. package/models/trace/insights/NetworkDependencyTree.js.map +1 -1
  196. package/models/trace/insights/RenderBlocking.d.ts +3 -1
  197. package/models/trace/insights/RenderBlocking.js +11 -1
  198. package/models/trace/insights/RenderBlocking.js.map +1 -1
  199. package/models/trace/insights/SlowCSSSelector.d.ts +17 -8
  200. package/models/trace/insights/SlowCSSSelector.js +39 -20
  201. package/models/trace/insights/SlowCSSSelector.js.map +1 -1
  202. package/models/trace/insights/ThirdParties.d.ts +3 -0
  203. package/models/trace/insights/ThirdParties.js +31 -0
  204. package/models/trace/insights/ThirdParties.js.map +1 -1
  205. package/models/trace/insights/Viewport.d.ts +2 -1
  206. package/models/trace/insights/Viewport.js +16 -0
  207. package/models/trace/insights/Viewport.js.map +1 -1
  208. package/models/trace/insights/types.d.ts +4 -1
  209. package/models/trace/insights/types.js +1 -0
  210. package/models/trace/insights/types.js.map +1 -1
  211. package/models/trace/lantern/graph/BaseNode.d.ts +1 -1
  212. package/models/trace/lantern/graph/BaseNode.js +1 -1
  213. package/models/trace/lantern/graph/BaseNode.js.map +1 -1
  214. package/models/trace/lantern/simulation/SimulationTimingMap.js +1 -1
  215. package/models/trace/lantern/simulation/SimulationTimingMap.js.map +1 -1
  216. package/models/trace/types/Configuration.d.ts +7 -0
  217. package/models/trace/types/Configuration.js +1 -0
  218. package/models/trace/types/Configuration.js.map +1 -1
  219. package/models/trace/types/Extensions.d.ts +14 -2
  220. package/models/trace/types/Extensions.js +5 -1
  221. package/models/trace/types/Extensions.js.map +1 -1
  222. package/models/trace/types/File.d.ts +3 -0
  223. package/models/trace/types/File.js.map +1 -1
  224. package/models/trace/types/Overlays.d.ts +115 -0
  225. package/models/trace/types/Overlays.js +5 -0
  226. package/models/trace/types/Overlays.js.map +1 -0
  227. package/models/trace/types/TraceEvents.d.ts +79 -36
  228. package/models/trace/types/TraceEvents.js +8 -13
  229. package/models/trace/types/TraceEvents.js.map +1 -1
  230. package/models/trace/types/types-tsconfig.json +1 -0
  231. package/models/trace/types/types.d.ts +1 -0
  232. package/models/trace/types/types.js +1 -0
  233. package/models/trace/types/types.js.map +1 -1
  234. package/package.json +1 -1
  235. package/test/test-trace-engine.mjs +1 -2
  236. package/core/platform/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  237. package/core/platform/platform.prebundle.d.ts +0 -18
  238. package/core/platform/platform.prebundle.js +0 -53
  239. package/core/platform/platform.prebundle.js.map +0 -1
  240. package/core/platform/platform.prebundle.ts +0 -71
  241. package/models/cpu_profile/cpu_profile.prebundle.d.ts +0 -3
  242. package/models/cpu_profile/cpu_profile.prebundle.js +0 -7
  243. package/models/cpu_profile/cpu_profile.prebundle.js.map +0 -1
  244. package/models/cpu_profile/cpu_profile.prebundle.ts +0 -11
  245. package/models/cpu_profile/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  246. package/models/trace/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -61
  247. package/models/trace/extras/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  248. package/models/trace/extras/extras.prebundle.d.ts +0 -7
  249. package/models/trace/extras/extras.prebundle.js +0 -11
  250. package/models/trace/extras/extras.prebundle.js.map +0 -1
  251. package/models/trace/extras/extras.prebundle.ts +0 -11
  252. package/models/trace/handlers/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  253. package/models/trace/handlers/handlers.prebundle.d.ts +0 -4
  254. package/models/trace/handlers/handlers.prebundle.js +0 -8
  255. package/models/trace/handlers/handlers.prebundle.js.map +0 -1
  256. package/models/trace/handlers/handlers.prebundle.ts +0 -8
  257. package/models/trace/helpers/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  258. package/models/trace/helpers/helpers.prebundle.d.ts +0 -7
  259. package/models/trace/helpers/helpers.prebundle.js +0 -11
  260. package/models/trace/helpers/helpers.prebundle.js.map +0 -1
  261. package/models/trace/helpers/helpers.prebundle.ts +0 -11
  262. package/models/trace/insights/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  263. package/models/trace/insights/insights.prebundle.d.ts +0 -4
  264. package/models/trace/insights/insights.prebundle.js +0 -8
  265. package/models/trace/insights/insights.prebundle.js.map +0 -1
  266. package/models/trace/insights/insights.prebundle.ts +0 -8
  267. package/models/trace/lantern/core/core.prebundle.d.ts +0 -2
  268. package/models/trace/lantern/core/core.prebundle.js +0 -6
  269. package/models/trace/lantern/core/core.prebundle.js.map +0 -1
  270. package/models/trace/lantern/core/core.prebundle.ts +0 -6
  271. package/models/trace/lantern/core/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  272. package/models/trace/lantern/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  273. package/models/trace/lantern/graph/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  274. package/models/trace/lantern/graph/graph.prebundle.d.ts +0 -4
  275. package/models/trace/lantern/graph/graph.prebundle.js +0 -8
  276. package/models/trace/lantern/graph/graph.prebundle.js.map +0 -1
  277. package/models/trace/lantern/graph/graph.prebundle.ts +0 -8
  278. package/models/trace/lantern/lantern.prebundle.d.ts +0 -6
  279. package/models/trace/lantern/lantern.prebundle.js +0 -10
  280. package/models/trace/lantern/lantern.prebundle.js.map +0 -1
  281. package/models/trace/lantern/lantern.prebundle.ts +0 -17
  282. package/models/trace/lantern/metrics/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  283. package/models/trace/lantern/metrics/metrics.prebundle.d.ts +0 -8
  284. package/models/trace/lantern/metrics/metrics.prebundle.js +0 -12
  285. package/models/trace/lantern/metrics/metrics.prebundle.js.map +0 -1
  286. package/models/trace/lantern/metrics/metrics.prebundle.ts +0 -12
  287. package/models/trace/lantern/simulation/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  288. package/models/trace/lantern/simulation/simulation.prebundle.d.ts +0 -6
  289. package/models/trace/lantern/simulation/simulation.prebundle.js +0 -10
  290. package/models/trace/lantern/simulation/simulation.prebundle.js.map +0 -1
  291. package/models/trace/lantern/simulation/simulation.prebundle.ts +0 -10
  292. package/models/trace/lantern/types/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  293. package/models/trace/lantern/types/types.prebundle.d.ts +0 -1
  294. package/models/trace/lantern/types/types.prebundle.js +0 -5
  295. package/models/trace/lantern/types/types.prebundle.js.map +0 -1
  296. package/models/trace/lantern/types/types.prebundle.ts +0 -5
  297. package/models/trace/trace.prebundle.d.ts +0 -10
  298. package/models/trace/trace.prebundle.js +0 -14
  299. package/models/trace/trace.prebundle.js.map +0 -1
  300. package/models/trace/trace.prebundle.ts +0 -25
  301. package/models/trace/types/devtools_entrypoint-bundle-tsconfig-tsconfig.json +0 -43
  302. package/models/trace/types/types.prebundle.d.ts +0 -5
  303. package/models/trace/types/types.prebundle.js +0 -9
  304. package/models/trace/types/types.prebundle.js.map +0 -1
  305. package/models/trace/types/types.prebundle.ts +0 -9
@@ -1 +1 @@
1
- {"version":3,"file":"LCPDiscovery.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LCPDiscovery.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAEL,eAAe,EACf,WAAW,EAGX,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,uBAAuB;IAC9B;;OAEG;IACH,WAAW,EACP,8NAA8N;IAClO;;;OAGG;IACH,YAAY,EAAE,oDAAoD;IAClE;;OAEG;IACH,oBAAoB,EAAE,4BAA4B;IAClD;;OAEG;IACH,4BAA4B,EAAE,sCAAsC;IACpE;;OAEG;IACH,mBAAmB,EAAE,6CAA6C;IAClE;;OAEG;IACH,kBAAkB,EAAE,uBAAuB;IAC3C;;OAEG;IACH,KAAK,EAAE,iBAAiB;IACxB;;OAEG;IACH,aAAa,EAAE,0DAA0D;CACjE,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI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AAC;YACzG,aAAa,EAAE,EAAC,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,EAAE,KAAK,EAAE,gBAAgB,KAAK,MAAM,EAAC;SACrG;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n type Checklist,\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n *@description Title of an insight that provides details about the LCP metric, and the network requests necessary to load it. Details how the LCP request was discoverable - in other words, the path necessary to load it (ex: network requests, JavaScript)\n */\n title: 'LCP request discovery',\n /**\n *@description Description of an insight that provides details about the LCP metric, and the network requests necessary to load it.\n */\n description:\n 'Optimize LCP by making the LCP image [discoverable](https://web.dev/articles/optimize-lcp#1_eliminate_resource_load_delay) from the HTML immediately, and [avoiding lazy-loading](https://web.dev/articles/lcp-lazy-loading)',\n /**\n * @description Text to tell the user how long after the earliest discovery time their LCP element loaded.\n * @example {401ms} PH1\n */\n lcpLoadDelay: 'LCP image loaded {PH1} after earliest start point.',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" is applied to the LCP request.\n */\n fetchPriorityApplied: 'fetchpriority=high applied',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" should be applied to the LCP request.\n */\n fetchPriorityShouldBeApplied: 'fetchpriority=high should be applied',\n /**\n * @description Text to tell the user that the LCP request is discoverable in the initial document.\n */\n requestDiscoverable: 'Request is discoverable in initial document',\n /**\n * @description Text to tell the user that the LCP request does not have the lazy load property applied.\n */\n lazyLoadNotApplied: 'lazy load not applied',\n /**\n * @description Text status indicating that the the Largest Contentful Paint (LCP) metric timing was not found. \"LCP\" is an acronym and should not be translated.\n */\n noLcp: 'No LCP detected',\n /**\n * @description Text status indicating that the Largest Contentful Paint (LCP) metric was text rather than an image. \"LCP\" is an acronym and should not be translated.\n */\n noLcpResource: 'No LCP resource detected because the LCP is not an image',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPDiscovery.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isLCPDiscovery(model: InsightModel): model is LCPDiscoveryInsightModel {\n return model.insightKey === 'LCPDiscovery';\n}\nexport type LCPDiscoveryInsightModel = InsightModel<typeof UIStrings, {\n lcpEvent?: Types.Events.LargestContentfulPaintCandidate,\n /** The network request for the LCP image, if there was one. */\n lcpRequest?: Types.Events.SyntheticNetworkRequest,\n earliestDiscoveryTimeTs?: Types.Timing.Micro,\n checklist?: Checklist<'priorityHinted'|'requestDiscoverable'|'eagerlyLoaded'>,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<LCPDiscoveryInsightModel>): LCPDiscoveryInsightModel {\n const relatedEvents = partialModel.lcpEvent && partialModel.lcpRequest ?\n // TODO: add entire request initiator chain?\n [partialModel.lcpEvent, partialModel.lcpRequest] :\n [];\n return {\n insightKey: InsightKeys.LCP_DISCOVERY,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.lcpRequest && partialModel.checklist &&\n (!partialModel.checklist.eagerlyLoaded.value || !partialModel.checklist.requestDiscoverable.value ||\n !partialModel.checklist.priorityHinted.value) ?\n 'fail' :\n 'pass',\n ...partialModel,\n relatedEvents,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LCPDiscoveryInsightModel {\n if (!context.navigation) {\n return finalize({});\n }\n\n const networkRequests = parsedTrace.NetworkRequests;\n\n const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);\n if (!frameMetrics) {\n throw new Error('no frame metrics');\n }\n\n const navMetrics = frameMetrics.get(context.navigationId);\n if (!navMetrics) {\n throw new Error('no navigation metrics');\n }\n const metricScore = navMetrics.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const lcpEvent = metricScore?.event;\n if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {\n return finalize({warnings: [InsightWarning.NO_LCP]});\n }\n\n const docRequest = networkRequests.byId.get(context.navigationId);\n if (!docRequest) {\n return finalize({warnings: [InsightWarning.NO_DOCUMENT_REQUEST]});\n }\n\n const lcpRequest = parsedTrace.LargestImagePaint.lcpRequestByNavigationId.get(context.navigationId);\n if (!lcpRequest) {\n return finalize({lcpEvent});\n }\n\n const initiatorUrl = lcpRequest.args.data.initiator?.url;\n // TODO(b/372319476): Explore using trace event HTMLDocumentParser::FetchQueuedPreloads to determine if the request\n // is discovered by the preload scanner.\n const initiatedByMainDoc =\n lcpRequest?.args.data.initiator?.type === 'parser' && docRequest.args.data.url === initiatorUrl;\n const imgPreloadedOrFoundInHTML = lcpRequest?.args.data.isLinkPreload || initiatedByMainDoc;\n\n const imageLoadingAttr = lcpEvent.args.data?.loadingAttr;\n const imageFetchPriorityHint = lcpRequest?.args.data.fetchPriorityHint;\n // This is the earliest discovery time an LCP request could have - it's TTFB.\n const earliestDiscoveryTime = docRequest?.args.data.timing ?\n Helpers.Timing.secondsToMicro(docRequest.args.data.timing.requestTime) +\n Helpers.Timing.milliToMicro(docRequest.args.data.timing.receiveHeadersStart) :\n undefined;\n\n const priorityHintFound = imageFetchPriorityHint === 'high';\n\n return finalize({\n lcpEvent,\n lcpRequest,\n earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.Micro(earliestDiscoveryTime) : undefined,\n checklist: {\n priorityHinted: {\n label: priorityHintFound ? i18nString(UIStrings.fetchPriorityApplied) :\n i18nString(UIStrings.fetchPriorityShouldBeApplied),\n value: priorityHintFound\n },\n requestDiscoverable: {label: i18nString(UIStrings.requestDiscoverable), value: imgPreloadedOrFoundInHTML},\n eagerlyLoaded: {label: i18nString(UIStrings.lazyLoadNotApplied), value: imageLoadingAttr !== 'lazy'},\n },\n });\n}\n"]}
1
+ {"version":3,"file":"LCPDiscovery.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LCPDiscovery.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAEL,eAAe,EACf,WAAW,EAGX,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,uBAAuB;IAC9B;;OAEG;IACH,WAAW,EACP,8NAA8N;IAClO;;;OAGG;IACH,YAAY,EAAE,oDAAoD;IAClE;;OAEG;IACH,oBAAoB,EAAE,4BAA4B;IAClD;;OAEG;IACH,4BAA4B,EAAE,sCAAsC;IACpE;;OAEG;IACH,mBAAmB,EAAE,6CAA6C;IAClE;;OAEG;IACH,kBAAkB,EAAE,uBAAuB;IAC3C;;OAEG;IACH,KAAK,EAAE,iBAAiB;IACxB;;OAEG;IACH,aAAa,EAAE,0DAA0D;CACjE,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,CAAC,CAAC;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AAE7E,MAAM,UAAU,cAAc,CAAC,KAAmB;IAChD,OAAO,KAAK,CAAC,UAAU,KAAK,cAAc,CAA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,EAAE,cAAc,EAAE,CAAC;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,2BAA2B,CACpD,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,GAAG,YAAY,CAAC,cAAc,CAAC,EACzE,YAAY,CAAC,OAAO,CAAC,EAAE,CAC1B,CAAC;IAEF,OAAO;QACL;YACE,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,YAAY,CAAC,OAAO;YAC3B,aAAa,EAAE,OAAO;SACvB;QACD;YACE,IAAI,EAAE,0BAA0B;YAChC,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,YAAY,CAAC,OAAO;SAC5B;QACD;YACE,IAAI,EAAE,oBAAoB;YAC1B,QAAQ,EAAE,CAAC;oBACT,MAAM,EAAE,KAAK;oBACb,uCAAuC;oBACvC,KAAK,EAAE,GAAG,YAAY,CAAC,cAAc,eAAe;oBACpD,YAAY,EAAE,KAAK;iBACpB,CAAC;YACF,KAAK,EAAE,YAAY,CAAC,OAAO;YAC3B,cAAc,EAAE,aAAa;SAC9B;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright 2024 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport * as Types from '../types/types.js';\n\nimport {\n type Checklist,\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n InsightWarning,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that provides details about the LCP metric, and the network requests necessary to load it. Details how the LCP request was discoverable - in other words, the path necessary to load it (ex: network requests, JavaScript)\n */\n title: 'LCP request discovery',\n /**\n * @description Description of an insight that provides details about the LCP metric, and the network requests necessary to load it.\n */\n description:\n 'Optimize LCP by making the LCP image [discoverable](https://web.dev/articles/optimize-lcp#1_eliminate_resource_load_delay) from the HTML immediately, and [avoiding lazy-loading](https://web.dev/articles/lcp-lazy-loading)',\n /**\n * @description Text to tell the user how long after the earliest discovery time their LCP element loaded.\n * @example {401ms} PH1\n */\n lcpLoadDelay: 'LCP image loaded {PH1} after earliest start point.',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" is applied to the LCP request.\n */\n fetchPriorityApplied: 'fetchpriority=high applied',\n /**\n * @description Text to tell the user that a fetchpriority property value of \"high\" should be applied to the LCP request.\n */\n fetchPriorityShouldBeApplied: 'fetchpriority=high should be applied',\n /**\n * @description Text to tell the user that the LCP request is discoverable in the initial document.\n */\n requestDiscoverable: 'Request is discoverable in initial document',\n /**\n * @description Text to tell the user that the LCP request does not have the lazy load property applied.\n */\n lazyLoadNotApplied: 'lazy load not applied',\n /**\n * @description Text status indicating that the the Largest Contentful Paint (LCP) metric timing was not found. \"LCP\" is an acronym and should not be translated.\n */\n noLcp: 'No LCP detected',\n /**\n * @description Text status indicating that the Largest Contentful Paint (LCP) metric was text rather than an image. \"LCP\" is an acronym and should not be translated.\n */\n noLcpResource: 'No LCP resource detected because the LCP is not an image',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LCPDiscovery.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport function isLCPDiscovery(model: InsightModel): model is LCPDiscoveryInsightModel {\n return model.insightKey === 'LCPDiscovery';\n}\nexport type LCPDiscoveryInsightModel = InsightModel<typeof UIStrings, {\n lcpEvent?: Types.Events.LargestContentfulPaintCandidate,\n /** The network request for the LCP image, if there was one. */\n lcpRequest?: Types.Events.SyntheticNetworkRequest,\n earliestDiscoveryTimeTs?: Types.Timing.Micro,\n checklist?: Checklist<'priorityHinted'|'requestDiscoverable'|'eagerlyLoaded'>,\n}>;\n\nfunction finalize(partialModel: PartialInsightModel<LCPDiscoveryInsightModel>): LCPDiscoveryInsightModel {\n const relatedEvents = partialModel.lcpEvent && partialModel.lcpRequest ?\n // TODO: add entire request initiator chain?\n [partialModel.lcpEvent, partialModel.lcpRequest] :\n [];\n return {\n insightKey: InsightKeys.LCP_DISCOVERY,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.lcpRequest && partialModel.checklist &&\n (!partialModel.checklist.eagerlyLoaded.value || !partialModel.checklist.requestDiscoverable.value ||\n !partialModel.checklist.priorityHinted.value) ?\n 'fail' :\n 'pass',\n ...partialModel,\n relatedEvents,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LCPDiscoveryInsightModel {\n if (!context.navigation) {\n return finalize({});\n }\n\n const networkRequests = parsedTrace.NetworkRequests;\n\n const frameMetrics = parsedTrace.PageLoadMetrics.metricScoresByFrameId.get(context.frameId);\n if (!frameMetrics) {\n throw new Error('no frame metrics');\n }\n\n const navMetrics = frameMetrics.get(context.navigationId);\n if (!navMetrics) {\n throw new Error('no navigation metrics');\n }\n const metricScore = navMetrics.get(Handlers.ModelHandlers.PageLoadMetrics.MetricName.LCP);\n const lcpEvent = metricScore?.event;\n if (!lcpEvent || !Types.Events.isLargestContentfulPaintCandidate(lcpEvent)) {\n return finalize({warnings: [InsightWarning.NO_LCP]});\n }\n\n const docRequest = networkRequests.byId.get(context.navigationId);\n if (!docRequest) {\n return finalize({warnings: [InsightWarning.NO_DOCUMENT_REQUEST]});\n }\n\n const lcpRequest = parsedTrace.LargestImagePaint.lcpRequestByNavigationId.get(context.navigationId);\n if (!lcpRequest) {\n return finalize({lcpEvent});\n }\n\n const initiatorUrl = lcpRequest.args.data.initiator?.url;\n // TODO(b/372319476): Explore using trace event HTMLDocumentParser::FetchQueuedPreloads to determine if the request\n // is discovered by the preload scanner.\n const initiatedByMainDoc =\n lcpRequest?.args.data.initiator?.type === 'parser' && docRequest.args.data.url === initiatorUrl;\n const imgPreloadedOrFoundInHTML = lcpRequest?.args.data.isLinkPreload || initiatedByMainDoc;\n\n const imageLoadingAttr = lcpEvent.args.data?.loadingAttr;\n const imageFetchPriorityHint = lcpRequest?.args.data.fetchPriorityHint;\n // This is the earliest discovery time an LCP request could have - it's TTFB.\n const earliestDiscoveryTime = docRequest?.args.data.timing ?\n Helpers.Timing.secondsToMicro(docRequest.args.data.timing.requestTime) +\n Helpers.Timing.milliToMicro(docRequest.args.data.timing.receiveHeadersStart) :\n undefined;\n\n const priorityHintFound = imageFetchPriorityHint === 'high';\n\n return finalize({\n lcpEvent,\n lcpRequest,\n earliestDiscoveryTimeTs: earliestDiscoveryTime ? Types.Timing.Micro(earliestDiscoveryTime) : undefined,\n checklist: {\n priorityHinted: {\n label: priorityHintFound ? i18nString(UIStrings.fetchPriorityApplied) :\n i18nString(UIStrings.fetchPriorityShouldBeApplied),\n value: priorityHintFound\n },\n requestDiscoverable: {label: i18nString(UIStrings.requestDiscoverable), value: imgPreloadedOrFoundInHTML},\n eagerlyLoaded: {label: i18nString(UIStrings.lazyLoadNotApplied), value: imageLoadingAttr !== 'lazy'},\n },\n });\n}\n\ninterface LCPImageDiscoveryData {\n checklist: Exclude<LCPDiscoveryInsightModel['checklist'], undefined>;\n request: Types.Events.SyntheticNetworkRequest;\n discoveryDelay: Types.Timing.Micro|null;\n estimatedSavings: Types.Timing.Milli|null;\n}\n\n/**\n * TODO: this extra transformation (getImageData) should not be necessary.\n */\nexport function getImageData(model: LCPDiscoveryInsightModel): LCPImageDiscoveryData|null {\n if (!model.lcpRequest || !model.checklist) {\n return null;\n }\n\n const shouldIncreasePriorityHint = !model.checklist.priorityHinted.value;\n const shouldPreloadImage = !model.checklist.requestDiscoverable.value;\n const shouldRemoveLazyLoading = !model.checklist.eagerlyLoaded.value;\n\n const imageLCP = shouldIncreasePriorityHint !== undefined && shouldPreloadImage !== undefined &&\n shouldRemoveLazyLoading !== undefined;\n\n // Shouldn't render anything if lcp insight is null or lcp is text.\n if (!imageLCP) {\n return null;\n }\n\n const data: LCPImageDiscoveryData = {\n checklist: model.checklist,\n request: model.lcpRequest,\n discoveryDelay: null,\n estimatedSavings: model.metricSavings?.LCP ?? null,\n };\n\n if (model.earliestDiscoveryTimeTs && model.lcpRequest) {\n const discoveryDelay = model.lcpRequest.ts - model.earliestDiscoveryTimeTs;\n data.discoveryDelay = Types.Timing.Micro(discoveryDelay);\n }\n\n return data;\n}\n\nexport function createOverlays(model: LCPDiscoveryInsightModel): Types.Overlays.Overlay[] {\n const imageResults = getImageData(model);\n if (!imageResults?.discoveryDelay) {\n return [];\n }\n\n const delay = Helpers.Timing.traceWindowFromMicroSeconds(\n Types.Timing.Micro(imageResults.request.ts - imageResults.discoveryDelay),\n imageResults.request.ts,\n );\n\n return [\n {\n type: 'ENTRY_OUTLINE',\n entry: imageResults.request,\n outlineReason: 'ERROR',\n },\n {\n type: 'CANDY_STRIPED_TIME_RANGE',\n bounds: delay,\n entry: imageResults.request,\n },\n {\n type: 'TIMESPAN_BREAKDOWN',\n sections: [{\n bounds: delay,\n // This is overridden in the component.\n label: `${imageResults.discoveryDelay} microseconds`,\n showDuration: false,\n }],\n entry: imageResults.request,\n renderLocation: 'ABOVE_EVENT',\n },\n ];\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type * as Handlers from '../handlers/handlers.js';
2
+ import type * as Types from '../types/types.js';
2
3
  import { type InsightModel, type InsightSetContext } from './types.js';
3
4
  export declare const UIStrings: {
4
5
  /**
@@ -28,5 +29,7 @@ type LegacyJavaScriptResults = Map<Handlers.ModelHandlers.Scripts.Script, Legacy
28
29
  export type LegacyJavaScriptInsightModel = InsightModel<typeof UIStrings, {
29
30
  legacyJavaScriptResults: LegacyJavaScriptResults;
30
31
  }>;
32
+ export declare function isLegacyJavaScript(model: InsightModel): model is LegacyJavaScriptInsightModel;
31
33
  export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LegacyJavaScriptInsightModel;
34
+ export declare function createOverlays(model: LegacyJavaScriptInsightModel): Types.Overlays.Overlay[];
32
35
  export {};
@@ -37,11 +37,11 @@ function finalize(partialModel) {
37
37
  ...partialModel,
38
38
  };
39
39
  }
40
+ export function isLegacyJavaScript(model) {
41
+ return model.insightKey === InsightKeys.LEGACY_JAVASCRIPT;
42
+ }
40
43
  export function generateInsight(parsedTrace, context) {
41
44
  const scripts = parsedTrace.Scripts.scripts.filter(script => {
42
- if (!context.navigation) {
43
- return false;
44
- }
45
45
  if (script.frame !== context.frameId) {
46
46
  return false;
47
47
  }
@@ -77,4 +77,13 @@ export function generateInsight(parsedTrace, context) {
77
77
  wastedBytes: wastedBytesByRequestId.values().reduce((acc, cur) => acc + cur, 0),
78
78
  });
79
79
  }
80
+ export function createOverlays(model) {
81
+ return [...model.legacyJavaScriptResults.keys()].map(script => script.request).filter(e => !!e).map(request => {
82
+ return {
83
+ type: 'ENTRY_OUTLINE',
84
+ entry: request,
85
+ outlineReason: 'ERROR',
86
+ };
87
+ });
88
+ }
80
89
  //# sourceMappingURL=LegacyJavaScript.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LegacyJavaScript.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LegacyJavaScript.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,mBAAmB,MAAM,6DAA6D,CAAC;AAEnG,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,iCAAiC,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3F,OAAO,EACL,eAAe,EACf,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,EAAC,sBAAsB,EAAC,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;AAEtE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,mBAAmB;I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ACrD,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GACR,IAAI,GAAG,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAEhH,OAAO,QAAQ,CAAC;QACd,uBAAuB,EAAE,MAAM;QAC/B,aAAa,EAAE,2BAA2B,CAAC,sBAAsB,EAAE,OAAO,CAAC;QAC3E,WAAW,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;KAChF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as LegacyJavaScriptLib from '../../../third_party/legacy-javascript/legacy-javascript.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\n\nimport {estimateCompressionRatioForScript, metricSavingsForWastedBytes} from './Common.js';\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nconst {detectLegacyJavaScript} = LegacyJavaScriptLib.LegacyJavaScript;\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that identifies polyfills for modern JavaScript features, and recommends their removal.\n */\n title: 'Legacy JavaScript',\n /**\n * @description Description of an insight that identifies polyfills for modern JavaScript features, and recommends their removal.\n */\n description:\n 'Polyfills and transforms enable older browsers to use new JavaScript features. However, many aren\\'t necessary for modern browsers. Consider modifying your JavaScript build process to not transpile [Baseline](https://web.dev/articles/baseline-and-polyfills) features, unless you know you must support older browsers. [Learn why most sites can deploy ES6+ code without transpiling](https://philipwalton.com/articles/the-state-of-es5-on-the-web/)',\n /** Label for a column in a data table; entries will be the individual JavaScript scripts. */\n columnScript: 'Script',\n /** Label for a column in a data table; entries will be the number of wasted bytes (aka the estimated savings in terms of bytes). */\n columnWastedBytes: 'Wasted bytes',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LegacyJavaScript.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport interface PatternMatchResult {\n name: string;\n line: number;\n column: number;\n}\n\ninterface LegacyJavaScriptResult {\n matches: PatternMatchResult[];\n estimatedByteSavings: number;\n}\n\ntype LegacyJavaScriptResults = Map<Handlers.ModelHandlers.Scripts.Script, LegacyJavaScriptResult>;\n\nexport type LegacyJavaScriptInsightModel = InsightModel<typeof UIStrings, {\n legacyJavaScriptResults: LegacyJavaScriptResults,\n}>;\n\nconst BYTE_THRESHOLD = 5000;\n\nfunction finalize(partialModel: PartialInsightModel<LegacyJavaScriptInsightModel>): LegacyJavaScriptInsightModel {\n const requests = [...partialModel.legacyJavaScriptResults.keys()].map(script => script.request).filter(e => !!e);\n\n return {\n insightKey: InsightKeys.LEGACY_JAVASCRIPT,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: requests.length ? 'fail' : 'pass',\n relatedEvents: [...new Set(requests)],\n ...partialModel,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LegacyJavaScriptInsightModel {\n const scripts = parsedTrace.Scripts.scripts.filter(script => {\n if (!context.navigation) {\n return false;\n }\n\n if (script.frame !== context.frameId) {\n return false;\n }\n\n if (script.url?.startsWith('chrome-extension://')) {\n return false;\n }\n\n return Helpers.Timing.timestampIsInBounds(context.bounds, script.ts);\n });\n\n const legacyJavaScriptResults: LegacyJavaScriptResults = new Map();\n const wastedBytesByRequestId = new Map<string, number>();\n\n for (const script of scripts) {\n if (!script.content || script.content.length < BYTE_THRESHOLD) {\n continue;\n }\n\n const result = detectLegacyJavaScript(script.content, script.sourceMap);\n if (result.estimatedByteSavings < BYTE_THRESHOLD) {\n continue;\n }\n\n // Translate from resource size to transfer size.\n const compressionRatio = estimateCompressionRatioForScript(script);\n const transferSize = Math.round(result.estimatedByteSavings * compressionRatio);\n result.estimatedByteSavings = transferSize;\n\n legacyJavaScriptResults.set(script, result);\n\n if (script.request) {\n const requestId = script.request.args.data.requestId;\n wastedBytesByRequestId.set(requestId, transferSize);\n }\n }\n\n const sorted =\n new Map([...legacyJavaScriptResults].sort((a, b) => b[1].estimatedByteSavings - a[1].estimatedByteSavings));\n\n return finalize({\n legacyJavaScriptResults: sorted,\n metricSavings: metricSavingsForWastedBytes(wastedBytesByRequestId, context),\n wastedBytes: wastedBytesByRequestId.values().reduce((acc, cur) => acc + cur, 0),\n });\n}\n"]}
1
+ {"version":3,"file":"LegacyJavaScript.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/LegacyJavaScript.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,mBAAmB,MAAM,6DAA6D,CAAC;AAEnG,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAGjD,OAAO,EAAC,iCAAiC,EAAE,2BAA2B,EAAC,MAAM,aAAa,CAAC;AAC3F,OAAO,EACL,eAAe,EACf,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,MAAM,EAAC,sBAAsB,EAAC,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;AAEtE,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,mBAAmB;IAC1B;;OAEG;IACH,WAAW,EACP,8bAA8b;IAClc,6FAA6F;IA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AG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GACR,IAAI,GAAG,CAAC,CAAC,GAAG,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAEhH,OAAO,QAAQ,CAAC;QACd,uBAAuB,EAAE,MAAM;QAC/B,aAAa,EAAE,2BAA2B,CAAC,sBAAsB,EAAE,OAAO,CAAC;QAC3E,WAAW,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,CAAC;KAChF,CAAC,CAAC;AACL,CAAC;AACD,MAAM,UAAU,cAAc,CAAC,KAAmC;IAChE,OAAO,CAAC,GAAG,KAAK,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QAC5G,OAAO;YACL,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,OAAO;YACd,aAAa,EAAE,OAAO;SACvB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as LegacyJavaScriptLib from '../../../third_party/legacy-javascript/legacy-javascript.js';\nimport type * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Types from '../types/types.js';\n\nimport {estimateCompressionRatioForScript, metricSavingsForWastedBytes} from './Common.js';\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type PartialInsightModel,\n} from './types.js';\n\nconst {detectLegacyJavaScript} = LegacyJavaScriptLib.LegacyJavaScript;\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that identifies polyfills for modern JavaScript features, and recommends their removal.\n */\n title: 'Legacy JavaScript',\n /**\n * @description Description of an insight that identifies polyfills for modern JavaScript features, and recommends their removal.\n */\n description:\n 'Polyfills and transforms enable older browsers to use new JavaScript features. However, many aren\\'t necessary for modern browsers. Consider modifying your JavaScript build process to not transpile [Baseline](https://web.dev/articles/baseline-and-polyfills) features, unless you know you must support older browsers. [Learn why most sites can deploy ES6+ code without transpiling](https://philipwalton.com/articles/the-state-of-es5-on-the-web/)',\n /** Label for a column in a data table; entries will be the individual JavaScript scripts. */\n columnScript: 'Script',\n /** Label for a column in a data table; entries will be the number of wasted bytes (aka the estimated savings in terms of bytes). */\n columnWastedBytes: 'Wasted bytes',\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/LegacyJavaScript.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport interface PatternMatchResult {\n name: string;\n line: number;\n column: number;\n}\n\ninterface LegacyJavaScriptResult {\n matches: PatternMatchResult[];\n estimatedByteSavings: number;\n}\n\ntype LegacyJavaScriptResults = Map<Handlers.ModelHandlers.Scripts.Script, LegacyJavaScriptResult>;\n\nexport type LegacyJavaScriptInsightModel = InsightModel<typeof UIStrings, {\n legacyJavaScriptResults: LegacyJavaScriptResults,\n}>;\n\nconst BYTE_THRESHOLD = 5000;\n\nfunction finalize(partialModel: PartialInsightModel<LegacyJavaScriptInsightModel>): LegacyJavaScriptInsightModel {\n const requests = [...partialModel.legacyJavaScriptResults.keys()].map(script => script.request).filter(e => !!e);\n\n return {\n insightKey: InsightKeys.LEGACY_JAVASCRIPT,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.ALL,\n state: requests.length ? 'fail' : 'pass',\n relatedEvents: [...new Set(requests)],\n ...partialModel,\n };\n}\n\nexport function isLegacyJavaScript(model: InsightModel): model is LegacyJavaScriptInsightModel {\n return model.insightKey === InsightKeys.LEGACY_JAVASCRIPT;\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): LegacyJavaScriptInsightModel {\n const scripts = parsedTrace.Scripts.scripts.filter(script => {\n if (script.frame !== context.frameId) {\n return false;\n }\n\n if (script.url?.startsWith('chrome-extension://')) {\n return false;\n }\n\n return Helpers.Timing.timestampIsInBounds(context.bounds, script.ts);\n });\n\n const legacyJavaScriptResults: LegacyJavaScriptResults = new Map();\n const wastedBytesByRequestId = new Map<string, number>();\n\n for (const script of scripts) {\n if (!script.content || script.content.length < BYTE_THRESHOLD) {\n continue;\n }\n\n const result = detectLegacyJavaScript(script.content, script.sourceMap);\n if (result.estimatedByteSavings < BYTE_THRESHOLD) {\n continue;\n }\n\n // Translate from resource size to transfer size.\n const compressionRatio = estimateCompressionRatioForScript(script);\n const transferSize = Math.round(result.estimatedByteSavings * compressionRatio);\n result.estimatedByteSavings = transferSize;\n\n legacyJavaScriptResults.set(script, result);\n\n if (script.request) {\n const requestId = script.request.args.data.requestId;\n wastedBytesByRequestId.set(requestId, transferSize);\n }\n }\n\n const sorted =\n new Map([...legacyJavaScriptResults].sort((a, b) => b[1].estimatedByteSavings - a[1].estimatedByteSavings));\n\n return finalize({\n legacyJavaScriptResults: sorted,\n metricSavings: metricSavingsForWastedBytes(wastedBytesByRequestId, context),\n wastedBytes: wastedBytesByRequestId.values().reduce((acc, cur) => acc + cur, 0),\n });\n}\nexport function createOverlays(model: LegacyJavaScriptInsightModel): Types.Overlays.Overlay[] {\n return [...model.legacyJavaScriptResults.keys()].map(script => script.request).filter(e => !!e).map(request => {\n return {\n type: 'ENTRY_OUTLINE',\n entry: request,\n outlineReason: 'ERROR',\n };\n });\n}\n"]}
@@ -22,12 +22,13 @@ export declare const UIStrings: {
22
22
  /**
23
23
  * @description Text explaining that there were not requests that were slowed down by using HTTP/1.1. "HTTP/1.1" should not be translated.
24
24
  */
25
- readonly noOldProtocolRequests: "No requests used HTTP/1.1";
25
+ readonly noOldProtocolRequests: "No requests used HTTP/1.1, or its current use of HTTP/1.1 does not present a significant optimization opportunity. HTTP/1.1 requests are only flagged if six or more static assets originate from the same origin, and they are not served from a local development environment or a third-party source.";
26
26
  };
27
27
  export declare const i18nString: (id: string, values?: Record<string, string> | undefined) => {i18nId: string, values: Record<string, string|number>, formattedDefault: string};
28
- export type UseModernHTTPInsightModel = InsightModel<typeof UIStrings, {
29
- requests: Types.Events.SyntheticNetworkRequest[];
28
+ export type ModernHTTPInsightModel = InsightModel<typeof UIStrings, {
29
+ http1Requests: Types.Events.SyntheticNetworkRequest[];
30
30
  }>;
31
+ export declare function isModernHTTP(model: InsightModel): model is ModernHTTPInsightModel;
31
32
  /**
32
33
  * Determine the set of resources that aren't HTTP/2 but should be.
33
34
  * We're a little conservative about what we surface for a few reasons:
@@ -47,5 +48,7 @@ export type UseModernHTTPInsightModel = InsightModel<typeof UIStrings, {
47
48
  * [2] https://www.twilio.com/blog/2017/10/http2-issues.html
48
49
  * [3] https://www.cachefly.com/http-2-is-not-a-magic-bullet/
49
50
  */
50
- export declare function determineNonHttp2Resources(requests: Types.Events.SyntheticNetworkRequest[], entityMappings: Handlers.Helpers.EntityMappings, firstPartyEntity: Handlers.Helpers.Entity | null): Types.Events.SyntheticNetworkRequest[];
51
- export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): UseModernHTTPInsightModel;
51
+ export declare function determineHttp1Requests(requests: Types.Events.SyntheticNetworkRequest[], entityMappings: Handlers.Helpers.EntityMappings, firstPartyEntity: Handlers.Helpers.Entity | null): Types.Events.SyntheticNetworkRequest[];
52
+ export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ModernHTTPInsightModel;
53
+ export declare function createOverlayForRequest(request: Types.Events.SyntheticNetworkRequest): Types.Overlays.EntryOutline;
54
+ export declare function createOverlays(model: ModernHTTPInsightModel): Types.Overlays.Overlay[];
@@ -26,10 +26,13 @@ export const UIStrings = {
26
26
  /**
27
27
  * @description Text explaining that there were not requests that were slowed down by using HTTP/1.1. "HTTP/1.1" should not be translated.
28
28
  */
29
- noOldProtocolRequests: 'No requests used HTTP/1.1'
29
+ noOldProtocolRequests: 'No requests used HTTP/1.1, or its current use of HTTP/1.1 does not present a significant optimization opportunity. HTTP/1.1 requests are only flagged if six or more static assets originate from the same origin, and they are not served from a local development environment or a third-party source.'
30
30
  };
31
31
  // const str_ = i18n.i18n.registerUIStrings('models/trace/insights/ModernHTTP.ts', UIStrings);
32
32
  export const i18nString = (i18nId, values) => ({i18nId, values}); // i18n.i18n.getLocalizedString.bind(undefined, str_);
33
+ export function isModernHTTP(model) {
34
+ return model.insightKey === InsightKeys.MODERN_HTTP;
35
+ }
33
36
  /**
34
37
  * Determines whether a network request is a "static resource" that would benefit from H2 multiplexing.
35
38
  * XHRs, tracking pixels, etc generally don't benefit as much because they aren't requested en-masse
@@ -75,8 +78,8 @@ function isMultiplexableStaticAsset(request, entityMappings, firstPartyEntity) {
75
78
  * [2] https://www.twilio.com/blog/2017/10/http2-issues.html
76
79
  * [3] https://www.cachefly.com/http-2-is-not-a-magic-bullet/
77
80
  */
78
- export function determineNonHttp2Resources(requests, entityMappings, firstPartyEntity) {
79
- const nonHttp2Resources = [];
81
+ export function determineHttp1Requests(requests, entityMappings, firstPartyEntity) {
82
+ const http1Requests = [];
80
83
  const groupedByOrigin = new Map();
81
84
  for (const record of requests) {
82
85
  const url = new URL(record.args.data.url);
@@ -112,9 +115,9 @@ export function determineNonHttp2Resources(requests, entityMappings, firstPartyE
112
115
  continue;
113
116
  }
114
117
  seenURLs.add(request.args.data.url);
115
- nonHttp2Resources.push(request);
118
+ http1Requests.push(request);
116
119
  }
117
- return nonHttp2Resources;
120
+ return http1Requests;
118
121
  }
119
122
  /**
120
123
  * Computes the estimated effect of all results being converted to http/2 on the provided graph.
@@ -148,11 +151,11 @@ function computeWasteWithGraph(urlsToChange, graph, simulator) {
148
151
  const savings = simulationBefore.timeInMs - simulationAfter.timeInMs;
149
152
  return Platform.NumberUtilities.floor(savings, 1 / 10);
150
153
  }
151
- function computeMetricSavings(nonHttp2Requests, context) {
154
+ function computeMetricSavings(http1Requests, context) {
152
155
  if (!context.navigation || !context.lantern) {
153
156
  return;
154
157
  }
155
- const urlsToChange = new Set(nonHttp2Requests.map(r => r.args.data.url));
158
+ const urlsToChange = new Set(http1Requests.map(r => r.args.data.url));
156
159
  const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;
157
160
  const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;
158
161
  return {
@@ -162,14 +165,14 @@ function computeMetricSavings(nonHttp2Requests, context) {
162
165
  }
163
166
  function finalize(partialModel) {
164
167
  return {
165
- insightKey: InsightKeys.IMAGE_DELIVERY,
168
+ insightKey: InsightKeys.MODERN_HTTP,
166
169
  strings: UIStrings,
167
170
  title: i18nString(UIStrings.title),
168
171
  description: i18nString(UIStrings.description),
169
172
  category: InsightCategory.LCP,
170
- state: partialModel.requests.length > 0 ? 'fail' : 'pass',
173
+ state: partialModel.http1Requests.length > 0 ? 'fail' : 'pass',
171
174
  ...partialModel,
172
- relatedEvents: partialModel.requests,
175
+ relatedEvents: partialModel.http1Requests,
173
176
  };
174
177
  }
175
178
  export function generateInsight(parsedTrace, context) {
@@ -177,11 +180,21 @@ export function generateInsight(parsedTrace, context) {
177
180
  const contextRequests = parsedTrace.NetworkRequests.byTime.filter(isWithinContext);
178
181
  const entityMappings = parsedTrace.NetworkRequests.entityMappings;
179
182
  const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;
180
- const firstPartyEntity = Handlers.Helpers.getEntityForUrl(firstPartyUrl, entityMappings.createdEntityCache);
181
- const nonHttp2Requests = determineNonHttp2Resources(contextRequests, entityMappings, firstPartyEntity ?? null);
183
+ const firstPartyEntity = Handlers.Helpers.getEntityForUrl(firstPartyUrl, entityMappings);
184
+ const http1Requests = determineHttp1Requests(contextRequests, entityMappings, firstPartyEntity ?? null);
182
185
  return finalize({
183
- requests: nonHttp2Requests,
184
- metricSavings: computeMetricSavings(nonHttp2Requests, context),
186
+ http1Requests,
187
+ metricSavings: computeMetricSavings(http1Requests, context),
185
188
  });
186
189
  }
190
+ export function createOverlayForRequest(request) {
191
+ return {
192
+ type: 'ENTRY_OUTLINE',
193
+ entry: request,
194
+ outlineReason: 'ERROR',
195
+ };
196
+ }
197
+ export function createOverlays(model) {
198
+ return model.http1Requests.map(req => createOverlayForRequest(req)) ?? [];
199
+ }
187
200
  //# sourceMappingURL=ModernHTTP.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ModernHTTP.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ModernHTTP.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,WAAW,GAKZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,aAAa;IACpB;;OAEG;IACH,WAAW,EACP,2LAA2L;IAC/L;;OAEG;IACH,OAAO,EAAE,SAAS;IAClB;;OAEG;IACH,QAAQ,EAAE,UAAU;IACpB;;OAEG;IACH,qBAAqB,EAAE,2BAA2B;CAC1C,CAAC;AAEX,MAAM,IAAI,GAAG,IAAI,CAAC,IAA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CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;QACzD,GAAG,YAAY;QACf,aAAa,EAAE,YAAY,CAAC,QAAQ;KACrC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC3B,WAAuC,EAAE,OAA0B;IACrE,MAAM,eAAe,GAAG,CAAC,KAAyB,EAAW,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAEtH,MAAM,eAAe,GAAG,WAAW,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAEnF,MAAM,cAAc,GAAG,WAAW,CAAC,eAAe,CAAC,cAAc,CAAC;IAClE,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,iBAAiB,IAAI,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;IACxG,MAAM,gBAAgB,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC,aAAa,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IAC5G,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,eAAe,EAAE,cAAc,EAAE,gBAAgB,IAAI,IAAI,CAAC,CAAC;IAE/G,OAAO,QAAQ,CAAC;QACd,QAAQ,EAAE,gBAAgB;QAC1B,aAAa,EAAE,oBAAoB,CAAC,gBAAgB,EAAE,OAAO,CAAC;KAC/D,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type MetricSavings,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. \"HTTP\" should not be translated.\n */\n title: 'Modern HTTP',\n /**\n * @description Description of an insight that recommends recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. \"HTTP\" should not be translated.\n */\n description:\n 'HTTP/2 and HTTP/3 offer many benefits over HTTP/1.1, such as multiplexing. [Learn more about using modern HTTP](https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2/).',\n /**\n * @description Column header for a table where each cell represents a network request.\n */\n request: 'Request',\n /**\n * @description Column header for a table where each cell represents the protocol of a network request.\n */\n protocol: 'Protocol',\n /**\n * @description Text explaining that there were not requests that were slowed down by using HTTP/1.1. \"HTTP/1.1\" should not be translated.\n */\n noOldProtocolRequests: 'No requests used HTTP/1.1'\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ModernHTTP.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type UseModernHTTPInsightModel = InsightModel<typeof UIStrings, {\n requests: Types.Events.SyntheticNetworkRequest[],\n}>;\n\n/**\n * Determines whether a network request is a \"static resource\" that would benefit from H2 multiplexing.\n * XHRs, tracking pixels, etc generally don't benefit as much because they aren't requested en-masse\n * for the same origin at the exact same time.\n */\nfunction isMultiplexableStaticAsset(\n request: Types.Events.SyntheticNetworkRequest, entityMappings: Handlers.Helpers.EntityMappings,\n firstPartyEntity: Handlers.Helpers.Entity|null): boolean {\n if (!Helpers.Network.STATIC_RESOURCE_TYPES.has(request.args.data.resourceType)) {\n return false;\n }\n\n // Resources from third-parties that are less than 100 bytes are usually tracking pixels, not actual resources.\n // They can masquerade as static types though (gifs, documents, etc)\n if (request.args.data.decodedBodyLength < 100) {\n const entity = entityMappings.entityByEvent.get(request);\n if (entity) {\n // Third-party assets are multiplexable in their first-party context.\n if (firstPartyEntity?.name === entity.name) {\n return true;\n }\n // Skip recognizable third-parties' requests.\n if (!entity.isUnrecognized) {\n return false;\n }\n }\n }\n\n return true;\n}\n\n/**\n * Determine the set of resources that aren't HTTP/2 but should be.\n * We're a little conservative about what we surface for a few reasons:\n *\n * - The simulator approximation of HTTP/2 is a little more generous than reality.\n * - There's a bit of debate surrounding HTTP/2 due to its worse performance in environments with high packet loss. [1][2][3]\n * - It's something that you'd have absolutely zero control over with a third-party (can't defer to fix it for example).\n *\n * Therefore, we only surface requests that were...\n *\n * - Served over HTTP/1.1 or earlier\n * - Served over an origin that serves at least 6 static asset requests\n * (if there aren't more requests than browser's max/host, multiplexing isn't as big a deal)\n * - Not served on localhost (h2 is a pain to deal with locally & and CI)\n *\n * [1] https://news.ycombinator.com/item?id=19086639\n * [2] https://www.twilio.com/blog/2017/10/http2-issues.html\n * [3] https://www.cachefly.com/http-2-is-not-a-magic-bullet/\n */\nexport function determineNonHttp2Resources(\n requests: Types.Events.SyntheticNetworkRequest[], entityMappings: Handlers.Helpers.EntityMappings,\n firstPartyEntity: Handlers.Helpers.Entity|null): Types.Events.SyntheticNetworkRequest[] {\n const nonHttp2Resources: Types.Events.SyntheticNetworkRequest[] = [];\n\n const groupedByOrigin = new Map<string, Types.Events.SyntheticNetworkRequest[]>();\n for (const record of requests) {\n const url = new URL(record.args.data.url);\n if (!isMultiplexableStaticAsset(record, entityMappings, firstPartyEntity)) {\n continue;\n }\n if (Helpers.Network.isSyntheticNetworkRequestLocalhost(record)) {\n continue;\n }\n const originRequests = Platform.MapUtilities.getWithDefault(groupedByOrigin, url.origin, () => []);\n originRequests.push(record);\n }\n\n const seenURLs = new Set<string>();\n\n for (const request of requests) {\n // Skip duplicates.\n if (seenURLs.has(request.args.data.url)) {\n continue;\n }\n\n // Check if record is not served through the service worker, servicer worker uses http/1.1 as a protocol.\n // These can generate false positives (bug: https://github.com/GoogleChrome/lighthouse/issues/7158).\n if (request.args.data.fromServiceWorker) {\n continue;\n }\n\n // Test the protocol to see if it was http/1.1.\n const isOldHttp = /HTTP\\/[01][.\\d]?/i.test(request.args.data.protocol);\n if (!isOldHttp) {\n continue;\n }\n\n const url = new URL(request.args.data.url);\n\n // Check if the origin has enough requests to bother flagging.\n const group = groupedByOrigin.get(url.origin) || [];\n if (group.length < 6) {\n continue;\n }\n\n seenURLs.add(request.args.data.url);\n nonHttp2Resources.push(request);\n }\n\n return nonHttp2Resources;\n}\n\n/**\n * Computes the estimated effect of all results being converted to http/2 on the provided graph.\n */\nfunction computeWasteWithGraph(\n urlsToChange: Set<string>, graph: Lantern.Graph.Node, simulator: Lantern.Simulation.Simulator): Types.Timing.Milli {\n const simulationBefore = simulator.simulate(graph);\n\n // Update all the protocols to reflect implementing our recommendations\n const originalProtocols = new Map();\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n if (!urlsToChange.has(node.request.url)) {\n return;\n }\n\n originalProtocols.set(node.request.requestId, node.request.protocol);\n node.request.protocol = 'h2';\n });\n\n const simulationAfter = simulator.simulate(graph);\n\n // Restore the original protocol after we've done our simulation\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n const originalProtocol = originalProtocols.get(node.request.requestId);\n if (originalProtocol === undefined) {\n return;\n }\n node.request.protocol = originalProtocol;\n });\n\n const savings = simulationBefore.timeInMs - simulationAfter.timeInMs;\n\n return Platform.NumberUtilities.floor(savings, 1 / 10) as Types.Timing.Milli;\n}\n\nfunction computeMetricSavings(\n nonHttp2Requests: Types.Events.SyntheticNetworkRequest[], context: InsightSetContext): MetricSavings|undefined {\n if (!context.navigation || !context.lantern) {\n return;\n }\n\n const urlsToChange = new Set(nonHttp2Requests.map(r => r.args.data.url));\n\n const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;\n const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;\n\n return {\n FCP: computeWasteWithGraph(urlsToChange, fcpGraph, context.lantern.simulator),\n LCP: computeWasteWithGraph(urlsToChange, lcpGraph, context.lantern.simulator),\n };\n}\n\nfunction finalize(partialModel: PartialInsightModel<UseModernHTTPInsightModel>): UseModernHTTPInsightModel {\n return {\n insightKey: InsightKeys.IMAGE_DELIVERY,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.requests.length > 0 ? 'fail' : 'pass',\n ...partialModel,\n relatedEvents: partialModel.requests,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): UseModernHTTPInsightModel {\n const isWithinContext = (event: Types.Events.Event): boolean => Helpers.Timing.eventIsInBounds(event, context.bounds);\n\n const contextRequests = parsedTrace.NetworkRequests.byTime.filter(isWithinContext);\n\n const entityMappings = parsedTrace.NetworkRequests.entityMappings;\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = Handlers.Helpers.getEntityForUrl(firstPartyUrl, entityMappings.createdEntityCache);\n const nonHttp2Requests = determineNonHttp2Resources(contextRequests, entityMappings, firstPartyEntity ?? null);\n\n return finalize({\n requests: nonHttp2Requests,\n metricSavings: computeMetricSavings(nonHttp2Requests, context),\n });\n}\n"]}
1
+ {"version":3,"file":"ModernHTTP.js","sourceRoot":"","sources":["../../../../../../../front_end/models/trace/insights/ModernHTTP.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,yEAAyE;AACzE,6BAA6B;AAE7B,OAAO,KAAK,IAAI,MAAM,4BAA4B,CAAC;AACnD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,QAAQ,MAAM,yBAAyB,CAAC;AACpD,OAAO,KAAK,OAAO,MAAM,uBAAuB,CAAC;AAIjD,OAAO,EACL,eAAe,EACf,WAAW,GAKZ,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB;;OAEG;IACH,KAAK,EAAE,aAAa;IACpB;;OAEG;IACH,WAAW,EACP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,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,OAAO;KACvB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAA6B;IAC1D,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,uBAAuB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["// Copyright 2025 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport * as i18n from '../../../core/i18n/i18n.js';\nimport * as Platform from '../../../core/platform/platform.js';\nimport * as Handlers from '../handlers/handlers.js';\nimport * as Helpers from '../helpers/helpers.js';\nimport type * as Lantern from '../lantern/lantern.js';\nimport type * as Types from '../types/types.js';\n\nimport {\n InsightCategory,\n InsightKeys,\n type InsightModel,\n type InsightSetContext,\n type MetricSavings,\n type PartialInsightModel,\n} from './types.js';\n\nexport const UIStrings = {\n /**\n * @description Title of an insight that recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. \"HTTP\" should not be translated.\n */\n title: 'Modern HTTP',\n /**\n * @description Description of an insight that recommends recommends using HTTP/2 over HTTP/1.1 because of the performance benefits. \"HTTP\" should not be translated.\n */\n description:\n 'HTTP/2 and HTTP/3 offer many benefits over HTTP/1.1, such as multiplexing. [Learn more about using modern HTTP](https://developer.chrome.com/docs/lighthouse/best-practices/uses-http2/).',\n /**\n * @description Column header for a table where each cell represents a network request.\n */\n request: 'Request',\n /**\n * @description Column header for a table where each cell represents the protocol of a network request.\n */\n protocol: 'Protocol',\n /**\n * @description Text explaining that there were not requests that were slowed down by using HTTP/1.1. \"HTTP/1.1\" should not be translated.\n */\n noOldProtocolRequests:\n 'No requests used HTTP/1.1, or its current use of HTTP/1.1 does not present a significant optimization opportunity. HTTP/1.1 requests are only flagged if six or more static assets originate from the same origin, and they are not served from a local development environment or a third-party source.'\n} as const;\n\nconst str_ = i18n.i18n.registerUIStrings('models/trace/insights/ModernHTTP.ts', UIStrings);\nexport const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);\n\nexport type ModernHTTPInsightModel = InsightModel<typeof UIStrings, {\n http1Requests: Types.Events.SyntheticNetworkRequest[],\n}>;\n\nexport function isModernHTTP(model: InsightModel): model is ModernHTTPInsightModel {\n return model.insightKey === InsightKeys.MODERN_HTTP;\n}\n\n/**\n * Determines whether a network request is a \"static resource\" that would benefit from H2 multiplexing.\n * XHRs, tracking pixels, etc generally don't benefit as much because they aren't requested en-masse\n * for the same origin at the exact same time.\n */\nfunction isMultiplexableStaticAsset(\n request: Types.Events.SyntheticNetworkRequest, entityMappings: Handlers.Helpers.EntityMappings,\n firstPartyEntity: Handlers.Helpers.Entity|null): boolean {\n if (!Helpers.Network.STATIC_RESOURCE_TYPES.has(request.args.data.resourceType)) {\n return false;\n }\n\n // Resources from third-parties that are less than 100 bytes are usually tracking pixels, not actual resources.\n // They can masquerade as static types though (gifs, documents, etc)\n if (request.args.data.decodedBodyLength < 100) {\n const entity = entityMappings.entityByEvent.get(request);\n if (entity) {\n // Third-party assets are multiplexable in their first-party context.\n if (firstPartyEntity?.name === entity.name) {\n return true;\n }\n // Skip recognizable third-parties' requests.\n if (!entity.isUnrecognized) {\n return false;\n }\n }\n }\n\n return true;\n}\n\n/**\n * Determine the set of resources that aren't HTTP/2 but should be.\n * We're a little conservative about what we surface for a few reasons:\n *\n * - The simulator approximation of HTTP/2 is a little more generous than reality.\n * - There's a bit of debate surrounding HTTP/2 due to its worse performance in environments with high packet loss. [1][2][3]\n * - It's something that you'd have absolutely zero control over with a third-party (can't defer to fix it for example).\n *\n * Therefore, we only surface requests that were...\n *\n * - Served over HTTP/1.1 or earlier\n * - Served over an origin that serves at least 6 static asset requests\n * (if there aren't more requests than browser's max/host, multiplexing isn't as big a deal)\n * - Not served on localhost (h2 is a pain to deal with locally & and CI)\n *\n * [1] https://news.ycombinator.com/item?id=19086639\n * [2] https://www.twilio.com/blog/2017/10/http2-issues.html\n * [3] https://www.cachefly.com/http-2-is-not-a-magic-bullet/\n */\nexport function determineHttp1Requests(\n requests: Types.Events.SyntheticNetworkRequest[], entityMappings: Handlers.Helpers.EntityMappings,\n firstPartyEntity: Handlers.Helpers.Entity|null): Types.Events.SyntheticNetworkRequest[] {\n const http1Requests: Types.Events.SyntheticNetworkRequest[] = [];\n\n const groupedByOrigin = new Map<string, Types.Events.SyntheticNetworkRequest[]>();\n for (const record of requests) {\n const url = new URL(record.args.data.url);\n if (!isMultiplexableStaticAsset(record, entityMappings, firstPartyEntity)) {\n continue;\n }\n if (Helpers.Network.isSyntheticNetworkRequestLocalhost(record)) {\n continue;\n }\n const originRequests = Platform.MapUtilities.getWithDefault(groupedByOrigin, url.origin, () => []);\n originRequests.push(record);\n }\n\n const seenURLs = new Set<string>();\n\n for (const request of requests) {\n // Skip duplicates.\n if (seenURLs.has(request.args.data.url)) {\n continue;\n }\n\n // Check if record is not served through the service worker, servicer worker uses http/1.1 as a protocol.\n // These can generate false positives (bug: https://github.com/GoogleChrome/lighthouse/issues/7158).\n if (request.args.data.fromServiceWorker) {\n continue;\n }\n\n // Test the protocol to see if it was http/1.1.\n const isOldHttp = /HTTP\\/[01][.\\d]?/i.test(request.args.data.protocol);\n if (!isOldHttp) {\n continue;\n }\n\n const url = new URL(request.args.data.url);\n\n // Check if the origin has enough requests to bother flagging.\n const group = groupedByOrigin.get(url.origin) || [];\n if (group.length < 6) {\n continue;\n }\n\n seenURLs.add(request.args.data.url);\n http1Requests.push(request);\n }\n\n return http1Requests;\n}\n\n/**\n * Computes the estimated effect of all results being converted to http/2 on the provided graph.\n */\nfunction computeWasteWithGraph(\n urlsToChange: Set<string>, graph: Lantern.Graph.Node, simulator: Lantern.Simulation.Simulator): Types.Timing.Milli {\n const simulationBefore = simulator.simulate(graph);\n\n // Update all the protocols to reflect implementing our recommendations\n const originalProtocols = new Map();\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n if (!urlsToChange.has(node.request.url)) {\n return;\n }\n\n originalProtocols.set(node.request.requestId, node.request.protocol);\n node.request.protocol = 'h2';\n });\n\n const simulationAfter = simulator.simulate(graph);\n\n // Restore the original protocol after we've done our simulation\n graph.traverse(node => {\n if (node.type !== 'network') {\n return;\n }\n const originalProtocol = originalProtocols.get(node.request.requestId);\n if (originalProtocol === undefined) {\n return;\n }\n node.request.protocol = originalProtocol;\n });\n\n const savings = simulationBefore.timeInMs - simulationAfter.timeInMs;\n\n return Platform.NumberUtilities.floor(savings, 1 / 10) as Types.Timing.Milli;\n}\n\nfunction computeMetricSavings(\n http1Requests: Types.Events.SyntheticNetworkRequest[], context: InsightSetContext): MetricSavings|undefined {\n if (!context.navigation || !context.lantern) {\n return;\n }\n\n const urlsToChange = new Set(http1Requests.map(r => r.args.data.url));\n\n const fcpGraph = context.lantern.metrics.firstContentfulPaint.optimisticGraph;\n const lcpGraph = context.lantern.metrics.largestContentfulPaint.optimisticGraph;\n\n return {\n FCP: computeWasteWithGraph(urlsToChange, fcpGraph, context.lantern.simulator),\n LCP: computeWasteWithGraph(urlsToChange, lcpGraph, context.lantern.simulator),\n };\n}\n\nfunction finalize(partialModel: PartialInsightModel<ModernHTTPInsightModel>): ModernHTTPInsightModel {\n return {\n insightKey: InsightKeys.MODERN_HTTP,\n strings: UIStrings,\n title: i18nString(UIStrings.title),\n description: i18nString(UIStrings.description),\n category: InsightCategory.LCP,\n state: partialModel.http1Requests.length > 0 ? 'fail' : 'pass',\n ...partialModel,\n relatedEvents: partialModel.http1Requests,\n };\n}\n\nexport function generateInsight(\n parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): ModernHTTPInsightModel {\n const isWithinContext = (event: Types.Events.Event): boolean => Helpers.Timing.eventIsInBounds(event, context.bounds);\n\n const contextRequests = parsedTrace.NetworkRequests.byTime.filter(isWithinContext);\n\n const entityMappings = parsedTrace.NetworkRequests.entityMappings;\n const firstPartyUrl = context.navigation?.args.data?.documentLoaderURL ?? parsedTrace.Meta.mainFrameURL;\n const firstPartyEntity = Handlers.Helpers.getEntityForUrl(firstPartyUrl, entityMappings);\n const http1Requests = determineHttp1Requests(contextRequests, entityMappings, firstPartyEntity ?? null);\n\n return finalize({\n http1Requests,\n metricSavings: computeMetricSavings(http1Requests, context),\n });\n}\n\nexport function createOverlayForRequest(request: Types.Events.SyntheticNetworkRequest): Types.Overlays.EntryOutline {\n return {\n type: 'ENTRY_OUTLINE',\n entry: request,\n outlineReason: 'ERROR',\n };\n}\n\nexport function createOverlays(model: ModernHTTPInsightModel): Types.Overlays.Overlay[] {\n return model.http1Requests.map(req => createOverlayForRequest(req)) ?? [];\n}\n"]}
@@ -129,6 +129,7 @@ export declare function handleLinkResponseHeader(linkHeaderValue: string): Array
129
129
  export declare function generatePreconnectedOrigins(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContextWithNavigation, contextRequests: Types.Events.SyntheticNetworkRequest[], preconnectCandidates: PreconnectCandidate[]): PreconnectedOrigin[];
130
130
  export declare function generatePreconnectCandidates(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContextWithNavigation, contextRequests: Types.Events.SyntheticNetworkRequest[]): PreconnectCandidate[];
131
131
  export declare function generateInsight(parsedTrace: Handlers.Types.ParsedTrace, context: InsightSetContext): NetworkDependencyTreeInsightModel;
132
+ export declare function createOverlays(model: NetworkDependencyTreeInsightModel): Types.Overlays.Overlay[];
132
133
  /**
133
134
  * http://tools.ietf.org/html/rfc3986#section-5.2.4
134
135
  */
@@ -313,12 +313,21 @@ export function handleLinkResponseHeader(linkHeaderValue) {
313
313
  return [];
314
314
  }
315
315
  const preconnectedOrigins = [];
316
- // const headerTextParts = linkHeaderValue.split(',');
317
316
  for (let i = 0; i < linkHeaderValue.length;) {
318
317
  const firstUrlEnd = linkHeaderValue.indexOf('>', i);
318
+ if (firstUrlEnd === -1) {
319
+ break;
320
+ }
319
321
  const commaIndex = linkHeaderValue.indexOf(',', firstUrlEnd);
320
322
  const partEnd = commaIndex !== -1 ? commaIndex : linkHeaderValue.length;
321
323
  const part = linkHeaderValue.substring(i, partEnd);
324
+ // This shouldn't be necessary, but we had a bug that created an infinite loop so
325
+ // let's guard against that.
326
+ // See crbug.com/431239629
327
+ if (partEnd + 1 <= i) {
328
+ console.warn('unexpected infinite loop, bailing');
329
+ break;
330
+ }
322
331
  i = partEnd + 1;
323
332
  const preconnectedOrigin = handleLinkResponseHeaderPart(part.trim());
324
333
  if (preconnectedOrigin) {
@@ -514,6 +523,21 @@ export function generateInsight(parsedTrace, context) {
514
523
  preconnectCandidates,
515
524
  });
516
525
  }
526
+ export function createOverlays(model) {
527
+ function walk(nodes, overlays) {
528
+ nodes.forEach(node => {
529
+ overlays.push({
530
+ type: 'ENTRY_OUTLINE',
531
+ entry: node.request,
532
+ outlineReason: 'ERROR',
533
+ });
534
+ walk(node.children, overlays);
535
+ });
536
+ }
537
+ const overlays = [];
538
+ walk(model.rootNodes, overlays);
539
+ return overlays;
540
+ }
517
541
  // the rest of this file is copied from core/common/common.js, which can't be bundled right now.
518
542
  /**
519
543
  * http://tools.ietf.org/html/rfc3986#section-5.2.4