Live data from Hacker News

Minify Your SVGs

victorzhou.com

31–40 of 66 posts

Re: Minify Your SVGs

#31
SVG optimization seems like a good choice for delivery, but oftentimes I find myself using SVG in a development context. Having human readable, annotated SVG files is useful when looking through previous revisions. In terms of compressed filesize: there's no serious practical gain.

Re: Minify Your SVGs

#32

We provide hosted service for optimising SVG. If anyone is interested for image optimisation as a service, take a look here: https://www.gumlet.com

Just another shameless plug here. I'm developing an SVG editor which focuses on generating clean and readable SVG files (e.g. no redundant namespaces, metadata or deeply nested structures).

You can try it online on https://boxy-svg.com, there are also desktop apps for macOS, Windows, Linux and Chrome OS.

Re: Minify Your SVGs

#33
post #15
post #2

Related: https://jakearchibald.github.io/svgomg/

I use it every time I'm using SVG for the web. My only problem is that when pasting SVG directly from Illustrator it finds an invalid character at the end and refuses to use it. I have to paste the SVG into an editor, remove some invisible character at the end, and then paste to svgomg. I reported this and offered to PR but never got an answer: https://github.com/jakearchibald/svgomg/issues/145

Is it legal to have a NUL byte in an SVG? Might want to also contact Illustrator as well if it's not.

Re: Minify Your SVGs

#34
Why? Why minify everything? It all gets gzipped at the HTTP layer anyway! I truly cannot understand this need to minify everything (JS included)

Re: Minify Your SVGs

#35
post #34

Why? Why minify everything? It all gets gzipped at the HTTP layer anyway! I truly cannot understand this need to minify everything (JS included)

It doesn't always get gzipped. That is highly dependent on the server.

Minification usually reduces code size, and some minifiers will also implement various optimizations.

Re: Minify Your SVGs

#36
post #15

Earlier quoted context omitted.

I use it every time I'm using SVG for the web. My only problem is that when pasting SVG directly from Illustrator it finds an invalid character at the end and refuses to use it. I have to paste the SVG into an editor, remove some invisible character at the end, and then paste to svgomg. I reported this and offered to PR but never got an answer: https://github.com/jakearchibald/svgomg/issues/145

Is it legal to have a NUL byte in an SVG? Might want to also contact Illustrator as well if it's not.

I doubt it, but I also doubt Adobe would pay attention...

Re: Minify Your SVGs

#37
post #16
post #4

Illustrator has an export SVG function (as opposed to just saving as an SVG, which I was doing and then using a minifer for a long time) that will minify it for you. That said, it currently appears unable to reopen those minified SVGs (go figure).

FYI you can copy any vector in Illustrator and when you paste it somewhere it is actually SVG code.

Which is why I fairly frequently end up with amusingly-long pastes of raw svg markup being posted into email fields... .

Re: Minify Your SVGs

#38
post #15

Earlier quoted context omitted.

I use it every time I'm using SVG for the web. My only problem is that when pasting SVG directly from Illustrator it finds an invalid character at the end and refuses to use it. I have to paste the SVG into an editor, remove some invisible character at the end, and then paste to svgomg. I reported this and offered to PR but never got an answer: https://github.com/jakearchibald/svgomg/issues/145

Is it legal to have a NUL byte in an SVG? Might want to also contact Illustrator as well if it's not.

It might be disallowed by XML already.

Re: Minify Your SVGs

#39

SVG optimization seems like a good choice for delivery, but oftentimes I find myself using SVG in a development context. Having human readable, annotated SVG files is useful when looking through previous revisions. In terms of compressed filesize: there's no serious practical gain.

It's analogous to JS minification -- Clients on the production site should get a bare minimum and the VCS should have the readable form with all the digits of precision and whatever comments, non-functional groups acting as layers in the editing software, etc.

Re: Minify Your SVGs

#40
Aren't garden variety SVG files ~75% smaller than other lossless compression methods (e.g. PNG). As such, is minification necessary or a best practice?

In short, is this an intellectual exercise or something that should be in an SVG producer's toolkit?

Post reply on HN