Live data from Hacker News

Minify Your SVGs

victorzhou.com

61–66 of 66 posts

Re: Minify Your SVGs

#61
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

Why ask, just write the PR and see if they'll take it.

I've done that in the past and some PRs are still there collecting dust.

Re: Minify Your SVGs

#62

Earlier quoted context omitted.

I was curious about this. It looks like it has numerous individual plugins that provide the actual functionality. Do you know if some of the plugins are lossless, while others lossy? It may be possible to pick and choose the lossless ones.

It has a boat load of plugins. I looked at a few and after puzzling over which were default enabled and default disabled I decided I didn't want to use a program with unsafe defaults.

That's fair.

Re: Minify Your SVGs

#63

This is neat, but I wonder: are there path optimization tools? For instance: flattening, removal of entirely occluded paths, and combination of paths.

Not exactly that but comes close (and perhaps could be used for that if you rasterized the input vector): https://vectormagic.com/

I haven’t used their desktop edition but on the web it worked really well for cleaning up images. I imagine similar algorithms could be applied directly to SVGs to simplify them.

Worth noting is the manual step in their workflow - I think there’s only so much you can do before you need a human to decide whether any important meaning has been lost.

Re: Minify Your SVGs

#64

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?

Raster formats have a worst-case file size that is linked to their visual size.

SVG has no such limit; for a given visual size it can have arbitrarily many objects. If you’re not careful, you can quite easily end up with multi-megabytes SVGs where a PNG would have been SVG is therefore a dangerous format to use if you don’t know what you’re doing, because its performance characteristics are quite unlike raster formats.

Re: Minify Your SVGs

#65
post #61

Earlier quoted context omitted.

Why ask, just write the PR and see if they'll take it.

I've done that in the past and some PRs are still there collecting dust.

Their loss. On the flip side, if anyone ever comes back or takes over the project, they'll have PR's ready to go.

Re: Minify Your SVGs

#66
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)

Because when the browser un-gzips it, it takes a lot more memory than the minified version. And everyone seems to complain about browser bloat.
Post reply on HN