Skip to content

Instantly share code, notes, and snippets.

@johndrinkwater
Created January 7, 2009 01:21
Show Gist options
  • Save johndrinkwater/44120 to your computer and use it in GitHub Desktop.
Save johndrinkwater/44120 to your computer and use it in GitHub Desktop.
Mini rant about SVG bloat, probably for a blog post
I love SVG.
I love Wikipedia.
I love Inkscape*.
But why do these three always work soo hard to fill the Internet with *large* files when such smaller ones could be stored and sent?
Why cant people learn to export as a *plain SVG*
john@ezri64 Desktop| ll Free*
-rw-rw-r-- 1 john john 4542 2009-01-07 01:08 Free-speech-flag.svg
-rw-rw-r-- 1 john john 1317 2009-01-07 00:42 Free-speech-flag.svg.gz
It wont break the Internet tubes to your house, or cost you anything more than 0.000001p on your roaming charges, but it’s still big, and it’s only for a 5 colour flag!
john@ezri64 Desktop| xmllint Free-speech-flag.svg > Free-speech-flag-linted.svg
john@ezri64 Desktop| ll Free-speech-flag-linted.svg
-rw-rw-r-- 1 john john 3940 2009-01-07 01:12 Free-speech-flag-linted.svg
Linting can only do soo much.
Some of the work requires looking through the SVG spec for initial values, and stripping those that don’t need to be set.
Then you can prune extra textspans Inkscape has inserted.
And change style=""s to attributes (each style="fill:#444444" loses you 6 bytes for no reason)
Strip all ids, unless they reference defs or use tags.
Cull that sodipodi:namedview block.
… and you’re just about done:
john@ezri64 Desktop| ll Free-speech-flag-optimised.svg*
-rw-rw-r-- 1 john john 1579 2009-01-07 01:07 Free-speech-flag-optimised.svg
-rw-rw-r-- 1 john john 691 2009-01-07 01:05 Free-speech-flag-optimised.svg.gz
That’s 2963 (3K) saved on the uncompressed file, 626 bytes on the compressed version.
Now explain to me why people forget to select plain SVG when exporting :/
*(I love FOSS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment