webperf-snippets 0.2.0 → 0.3.0

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 (65) hide show
  1. package/README.md +120 -5
  2. package/package.json +1 -1
  3. package/snippets/CoreWebVitals/CLS.js +29 -15
  4. package/snippets/CoreWebVitals/INP.js +14 -7
  5. package/snippets/CoreWebVitals/LCP-Image-Entropy.js +29 -11
  6. package/snippets/CoreWebVitals/LCP-Subparts.js +4 -0
  7. package/snippets/CoreWebVitals/LCP-Trail.js +14 -3
  8. package/snippets/CoreWebVitals/LCP-Video-Candidate.js +20 -2
  9. package/snippets/CoreWebVitals/LCP.js +4 -2
  10. package/snippets/DevTools-Overrides/Fetch-XHR-Timeline-read.js +9 -2
  11. package/snippets/Interaction/DOM-Size-and-Depth.js +134 -0
  12. package/snippets/Interaction/Forced-Synchronous-Layout.js +33 -7
  13. package/snippets/Interaction/Input-Latency-Breakdown.js +45 -1
  14. package/snippets/Interaction/Interactions.js +16 -5
  15. package/snippets/Interaction/Layout-Shift-Loading-and-Interaction.js +44 -13
  16. package/snippets/Interaction/Long-Animation-Frames-Helpers.js +28 -1
  17. package/snippets/Interaction/Long-Animation-Frames-Script-Attribution.js +8 -0
  18. package/snippets/Interaction/Long-Animation-Frames.js +31 -2
  19. package/snippets/Interaction/LongTask.js +37 -5
  20. package/snippets/Interaction/Scroll-Performance.js +40 -0
  21. package/snippets/Interaction/WORKFLOWS.md +9 -0
  22. package/snippets/Loading/Back-Forward-Cache.js +174 -381
  23. package/snippets/Loading/CSS-Media-Queries-Analysis.js +76 -44
  24. package/snippets/Loading/Cache-Strategy-Analysis.js +52 -30
  25. package/snippets/Loading/Compression-Audit.js +172 -0
  26. package/snippets/Loading/Content-Visibility.js +8 -3
  27. package/snippets/Loading/Critical-CSS-Detection.js +8 -6
  28. package/snippets/Loading/Event-Processing-Time.js +15 -2
  29. package/snippets/Loading/FCP.js +39 -5
  30. package/snippets/Loading/Find-Above-The-Fold-Lazy-Loaded-Images.js +1 -1
  31. package/snippets/Loading/Find-non-Lazy-Loaded-Images-outside-of-the-viewport.js +7 -5
  32. package/snippets/Loading/First-And-Third-Party-Script-Info.js +40 -20
  33. package/snippets/Loading/First-And-Third-Party-Script-Timings.js +21 -13
  34. package/snippets/Loading/Fonts-Preloaded-Loaded-and-used-above-the-fold.js +35 -4
  35. package/snippets/Loading/Inline-CSS-Info-and-Size.js +8 -6
  36. package/snippets/Loading/Inline-Script-Info-and-Size.js +14 -7
  37. package/snippets/Loading/JS-Execution-Time-Breakdown.js +23 -10
  38. package/snippets/Loading/Priority-Hints-Audit.js +4 -1
  39. package/snippets/Loading/Resource-Hints-Validation.js +15 -0
  40. package/snippets/Loading/Resource-Hints.js +29 -8
  41. package/snippets/Loading/SSR-Hydration-Data-Analysis.js +77 -8
  42. package/snippets/Loading/Script-Loading.js +55 -25
  43. package/snippets/Loading/Server-Timing-Early-Hints.js +126 -0
  44. package/snippets/Loading/Service-Worker-Analysis.js +229 -53
  45. package/snippets/Loading/Speculation-Rules-Inspector.js +134 -0
  46. package/snippets/Loading/TTFB-Resources.js +59 -18
  47. package/snippets/Loading/TTFB-Sub-Parts.js +9 -2
  48. package/snippets/Loading/TTFB.js +3 -2
  49. package/snippets/Loading/Third-Party-Impact-by-Domain.js +216 -0
  50. package/snippets/Loading/Validate-Preload-Async-Defer-Scripts.js +21 -3
  51. package/snippets/Loading/WORKFLOWS.md +47 -1
  52. package/snippets/Loading/Webfont-Usage-Analyzer.js +332 -0
  53. package/snippets/Media/Image-Element-Audit.js +22 -3
  54. package/snippets/Media/Oversized-Images.js +217 -0
  55. package/snippets/Media/SVG-Embedded-Bitmap-Analysis.js +18 -3
  56. package/snippets/Media/WORKFLOWS.md +22 -0
  57. package/snippets/Resources/Network-Bandwidth-Connection-Quality.js +7 -0
  58. package/snippets/SCHEMA.md +1176 -0
  59. package/snippets/_shared/helpers.js +44 -0
  60. package/src/bin.js +55 -3
  61. package/src/crux.js +84 -0
  62. package/src/report-to.js +46 -0
  63. package/src/reporters/human.js +20 -1
  64. package/src/reporters/markdown.js +22 -1
  65. package/src/runner.js +4 -2
@@ -19,6 +19,15 @@ When the user asks "optimize images" or "check image performance":
19
19
  - Find-Images-With-Lazy-and-Fetchpriority.js (contradictory attributes)
20
20
  - Priority-Hints-Audit.js (LCP image should have fetchpriority="high")
21
21
 
22
+ ### Oversized Images Audit
23
+
24
+ When the user asks about images larger than needed, wasted bytes, blurry images, or `srcset`/`sizes` problems:
25
+
26
+ 1. **Oversized-Images.js** - Compare each image file with the pixels drawn (oversized and undersized)
27
+ 2. **Image-Element-Audit.js** - Check format, lazy loading and `srcset` usage of the flagged images
28
+ 3. Cross-reference with **webperf-core-web-vitals** skill:
29
+ - LCP.js (check whether an oversized image is the LCP element)
30
+
22
31
  ### Video Performance Audit
23
32
 
24
33
  When the user asks "optimize videos" or "check video performance":
@@ -106,6 +115,19 @@ Use this decision tree to automatically run follow-up snippets based on results:
106
115
 
107
116
  - **If images missing alt text** → Accessibility issue, recommend adding descriptive alt text
108
117
 
118
+ ### After Oversized-Images.js
119
+
120
+ - **If oversized images found** → Recommend:
121
+ - `srcset` with several widths and an accurate `sizes` attribute
122
+ - Resizing at build time or with an image CDN
123
+ - Run **Image-Element-Audit.js** to check format and lazy loading of the same images
124
+
125
+ - **If an oversized image is the LCP element** → Run **webperf-core-web-vitals:LCP.js** and **LCP-Subparts.js** (large files inflate resource load duration)
126
+
127
+ - **If undersized (blurry) images found** → Recommend a source with at least the needed pixels and a `2x` candidate for high-density screens
128
+
129
+ - **If skipped images are lazy-loaded** → Scroll to the end of the page and run the snippet again
130
+
109
131
  ### After Video-Element-Audit.js
110
132
 
111
133
  - **If video is LCP candidate** → Run:
@@ -89,9 +89,16 @@
89
89
 
90
90
  console.groupEnd();
91
91
 
92
+ const connectionRating =
93
+ effectiveType === "4g" ? "good"
94
+ : effectiveType === "3g" ? "needs-improvement"
95
+ : effectiveType === "2g" || effectiveType === "slow-2g" ? "poor"
96
+ : undefined;
97
+
92
98
  return {
93
99
  script: "Network-Bandwidth-Connection-Quality",
94
100
  status: "ok",
101
+ ...(connectionRating !== undefined ? { rating: connectionRating } : {}),
95
102
  details: {
96
103
  effectiveType,
97
104
  downlink: connection.downlink,