The Four Numbers Worth Recording Before and After Optimization
- Raw UTF-8 byte length: Reported live inside the SVG Nexus SVG Optimizer (which displays actual byte delta per file rather than generic estimates). Raw size matters for JS/HTML parse buffers and CSS Data URI length.
- Compressed wire bytes (Brotli / Gzip): Removing 400 bytes of indented spaces may save only ~30 bytes after Brotli, whereas stripping unique 6-decimal path digits or embedded editor metadata saves real wire bytes because random decimals don't compress well!
- Parsed DOM element count: Collapsing five nested
<g>wrappers and unused<clipPath>nodes directly lowers browser memory and style-recalc work. - Visual fidelity at both 16px and 256px: A tiny byte count means nothing if rounding coordinates to 2 decimals warped a brand curve or stripped
fill-rule="evenodd".
Reproducible Local Node.js Snippet to Measure Any SVG Folder
import fs from "node:fs";
import zlib from "node:zlib";
function inspectSvgPayload(filePath) {
const buf = fs.readFileSync(filePath);
const xml = buf.toString("utf8");
const gzipBytes = zlib.gzipSync(buf, { level: 9 }).byteLength;
const brotliBytes = zlib.brotliCompressSync(buf).byteLength;
const tagCount = (xml.match(/<[a-zA-Z][^>]*>/g) || []).length;
return {
file: filePath,
rawBytes: buf.byteLength,
gzipBytes,
brotliBytes,
elementTags: tagCount,
};
}
console.table([
inspectSvgPayload("./before-export.svg"),
inspectSvgPayload("./after-optimized.svg"),
]);Always pair byte measurements with a side-by-side XML inspection in our Diff & Patch Studio so you know exactly which attributes or <defs> nodes were removed.