SVG optimisation — audit and verified pilots

Scope: the 74 SVG files in after/core/themes/default_admin/images/ (41,981 bytes total). This is a measurement plus two bounded pilots and a cleanup batch, not a bulk rewrite.

Opportunity, in order of value

Item Bytes Share of total Risk
Unused after-side assets 11,068 removed; 558 pending 26.4% removed Delete rather than optimise
Two identical file-type pairs 1,546 redundant 3.7% Low; deduplicate the CSS URL, not the artwork
Whitespace/comments between tags 1,411 3.4% Low; lossless
SVGO 4-decimal path conversion, all 74 9,214 21.9% Not yet validated per file; geometry/path data changes
SVGO 3-decimal path conversion ~10,700 ~25% Rejected: measured pixel differences at 24–192px

Total SVG payload is small. Removing dead assets is a bigger, safer win than minifying used paths. Delivery compression and caching will matter more than a few hundred bytes for the used set.

Pilot: icons/required.svg

Tool: SVGO 3.3.5, run only in /tmp, no repository dependency.

Config properties: preset-default with removeViewBox: false, cleanupIds: false, removeTitle/Desc/Metadata/Comments: false, convertColors: false, mergePaths: false, convertShapeToPath: false, convertPathData at 4 decimals, multipass: false.

File Before After Saving
icons/required.svg 1,130 B 920 B 18.6%
icons/logos/drupal.svg (pilot only, not applied) 1,610 B 1,222 B 24.1%

Pixel comparison (transparent canvas, RGBA, exact per-pixel diff):

Asset 16px 24px 32px 42px 64px 192px
required, 4 decimals 0 0 0 0 0 0
drupal, 4 decimals 0 0 0 0 0 0
required, 3 decimals 0 5 px (Δ64) 2 px (Δ64) 2 px (Δ64) 4 px (Δ64) 23 px (Δ64)
drupal, 3 decimals 0 0 0 0 0 8 px (Δ64)

4-decimal output was pixel-identical at all tested sizes for both pilot assets. 3-decimal output was rejected. The path data was rewritten to relative/shorthand commands; this is not byte-identical geometry, so pixel equality at tested sizes is evidence, not proof at every scale or renderer.

Pilot patch: proposed/interdiff-svg-optimization-required.patch (1 file; 920 bytes). Report: this file.

Rules for a batch pass

  1. Remove unused assets first. Do not spend optimisation effort on the 16 files with no consumer.
  2. Do not remove viewBox, currentColor, IDs, titles/descriptions, metadata or licence comments.
  3. Do not merge paths or convert shapes unless each file is separately reviewed; stroke order, fill rules and holes can change.
  4. 4 decimals is the floor for a batch pilot. 3 decimals produced visible antialias differences in the pilot.
  5. Per-file pixel comparison at 16/24/32/42/64/192 plus the actual component size, in light/dark/forced colours where relevant.
  6. Actual Drupal component test for each optimised asset family before merging; standalone raster equality is not enough.
  7. No bulk optimisation mixed with functional fixes. One family or one asset per commit.
  8. Preserve provenance. If an asset has a licence/title/description, keep it.
  9. No mass reformatting of files that are already small (under ~300 bytes) — the gain is negligible and review noise is high.
  10. Do not optimise removed/pretint assets blindly. Pretints are frozen colour snapshots; confirm their mode/state table first.

Decision

The first pilot applied required.svg. The batch execution below adds the 14-file unused-asset cleanup and the five-icon status family; other assets remain unchanged. Actual full-MR-theme Drupal testing is still pending.

Applied: unused-asset cleanup

Removed from proposed after confirming no consumer references:

appearance, blocks, bookmarks, content, files, media, nav-toggle-left, nav-toggle-top, people, reports, structure, user, pretint/chevron-down-default, pretint/remove-default.

Applied: status-icon family at 4 decimals

Five used assets, same SVGO settings as the required.svg pilot:

Asset Before After Saving Pixel check
icons/clock.svg 279 244 12.5% identical 16–192px
icons/server.svg 415 364 12.3% identical 16–192px
icons/database.svg 349 306 12.3% identical 16–192px
logos/drupal.svg 1,610 1,223 24.0% identical 16–192px; 1 edge pixel at 512px
logos/php.svg 1,211 1,192 1.6% identical 16–512px

Total: 535 bytes saved (13.8%) on the family. Tests: proposed/tests/svg_optimization_status_family.py (4 tests, passing). Patch: proposed/interdiff-svg-optimization-status-family.patch.

The one 512px edge-pixel difference for the Drupal logo is at a non-UI scale; it is recorded rather than hidden. The optimized family has not yet been installed into a full MR-theme Drupal site; the existing live status test used the pre-optimisation assets and the forced-colours CSS fix.

Deferred with reasons

Result

After-side baseline: 74 files / 41,981 bytes. Proposed tree after cleanup and the two optimisation pilots: 61 files / 30,380 bytes — 11,601 bytes less (27.6%). The proposed tree also adds pretint/check-disabled-inverse.svg, so the reduction is net of that addition.