You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Detect standalone inline SVGs vs those already using the sprite pattern
and show the breakdown in the summary line
- Add SVG Sprite Opportunity tip when 5+ standalone inline SVGs are found
- Suppress Promise return value with void IIFE
- Document the sprite tip and update Further Reading with <use> MDN link
| External SVG files | Count of SVG resources captured by the Performance API (loaded via `<img>`, `<object>`, CSS, fetch, etc.) |
225
-
| Inline `<svg>` elements | Count of `<svg>` elements present in the DOM|
255
+
| Inline `<svg>` elements | Count of `<svg>` elements present in the DOM. When some already use the sprite pattern the breakdown shows `N using <use>, M standalone`|
226
256
| SVGs with bitmaps | SVGs (external or inline) that contain at least one embedded bitmap |
227
257
228
258
#### External SVG Resources Table
@@ -253,11 +283,36 @@ The correct pattern is to reference bitmap assets as separate files:
253
283
| 🖼️ |`inline`| Base64-encoded bitmap embedded directly as a `data:image/…;base64,` URI. The reported size is an estimate derived from the base64 string length |
254
284
| 🔗 |`external`| Bitmap file referenced via `href` or `xlink:href` on an `<image>` element. The bitmap is a separate HTTP request, but it is still discovered only after the SVG has loaded |
255
285
286
+
#### SVG Sprite Opportunity
287
+
288
+
When 5 or more standalone inline `<svg>` elements are detected (i.e. not already using `<use>`), the snippet shows a tip suggesting the SVG sprite pattern.
289
+
290
+
Inline SVGs repeated across a page inflate HTML size and cannot be cached independently. The sprite pattern defines each icon once as a `<symbol>` in a hidden `<svg>` block and references it anywhere with `<use href="#id">`:
291
+
292
+
```html
293
+
<!-- Define once (hidden, ideally in a separate .svg file loaded via fetch or server-side include) -->
The summary line for inline `<svg>` elements shows a breakdown when the sprite pattern is already partially in use:
305
+
306
+
```
307
+
Inline <svg> elements : 211 (5 using <use>, 206 standalone)
308
+
```
309
+
256
310
> **CORS note**: The snippet fetches each SVG with `cache: "force-cache"` to read headers and content without triggering new network requests. Cross-origin SVGs without CORS headers cannot be read — in that case the snippet falls back to Performance API timing data for size and compression, and bitmap detection is skipped for that resource.
0 commit comments