Be aware that svgo is a lossy operation. One thing it does is round the digits in numbers to a certain precision. When I last worked with it, it also did some things I did not like such as mess with viewboxes. I found that it messed up the sizing of SVGs embedded with tags in certain browsers. It has been a while since I used it though.
Minify Your SVGs
51–60 of 66 posts
Re: Minify Your SVGs
#52In general I'd recommend the opposite: don't minify anything unless necessary, prettify it instead. Every plaintext-based format file should be optimized for human readability unless you actually need to make it hard to read (e.g. you are developing a proprietary product not meant to be open-source) or your bandwidth is limited so severely that every single byte matters. Nevertheless the kind of minification demonstr…
Re: Minify Your SVGs
#53In general I'd recommend the opposite: don't minify anything unless necessary, prettify it instead. Every plaintext-based format file should be optimized for human readability unless you actually need to make it hard to read (e.g. you are developing a proprietary product not meant to be open-source) or your bandwidth is limited so severely that every single byte matters. Nevertheless the kind of minification demonstr…
Even in the first world, on a spotty mobile connection every single byte matters, and some of your users are almost always going to be in that situation some of the time.
Think of minifying as "compiling" for the web. A good dev makes their site performant, and doesn't care about generating readable source code for end-users which 99.9% of them don't care about.
If you want to expose the site's source code to the world in a readable format, then just publish it on GitHub as well, which is the audience that might actually care.
Readable plaintext files are for developers on your team. Not for end users of your product.
Re: Minify Your SVGs
#54SVG 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
#55I've also noticed the cruft in Inkscape SVG's. The TXR logo SVG is cleaned with a TXR script: http://www.kylheku.com/cgit/txr/tree/win/cleansvg.txr The original looks like this: http://www.kylheku.com/cgit/txr/tree/win/txr.svg The cleaned one is not in the repo. It's obtained by "txr cleansvg.txr txr.svg":
Re: Minify Your SVGs
#56Pro tip for people with SVGs that have an image inside. You can pull that base64 image out of the svg, convert to image, compress it (tinypng, pngcrush etc) then convert back to base64 and out back in the SVG. We automated this with a slackbot but it’s often overlooked with all SVG optimization scripts.
Somewhat related: a while ago realized that the SVGs that draw.io generates (exports) have an interesting property. If you include an SVG inside such a drawing and you export it to SVG, that SVG is actually embedded as base64. This is unfortunately not supported by some programs (e.g., Microsoft Office). A quick fix is to actually expand the SVG into the big SVG. I wrote a quick tool for this that does this for you (…
Re: Minify Your SVGs
#57Be aware that svgo is a lossy operation. One thing it does is round the digits in numbers to a certain precision. When I last worked with it, it also did some things I did not like such as mess with viewboxes. I found that it messed up the sizing of SVGs embedded with tags in certain browsers. It has been a while since I used it though.
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.
Re: Minify Your SVGs
#58I've seen this on a number of other blogs, which seem to focus on minimal design. Can anyone explain what the need is for these enormous favicons?
Re: Minify Your SVGs
#59I love seeing efforts to make software more efficient, so I enjoyed this post, but at the same time your own blog has a 434kb 512x512 png favicon. I'm not at all a web developer and so I don't know if there is a technical reason for that, but it seems a bit absurd in juxtaposition to your goal to reduce a 2kb svg to 100 bytes. I've seen this on a number of other blogs, which seem to focus on minimal design. Can anyon…
Was intended for web apps I believe but is usable by sites that aren't web apps.
Read more here: https://developers.google.com/web/fundamentals/web-app-manif...
Re: Minify Your SVGs
#60Related: 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