5 ms·
This looks very good, especially as a teaching tool. Writing and minifying SVG by hand (including path data) is a hobby of mine. I’m pleased to see that the mi
by chrismorgan 6y ago
This looks very good, especially as a teaching tool. Writing and minifying SVG by hand (including path data) is a hobby of mine.
I’m pleased to see that the minification doesn’t put a space after the “0” or “1” of large-arc-flag and sweep-flag; historically I’ve found most minification tools doing so, and even some tools failing to parse `a1 2 3 104 5` (arc: rx=1, ry=2, x-axis-rotation=3, large-arc-flag enabled, sweep-flag disabled, dx=4, dy=5).
One missing optimisation is culling superfluous path commands. If you have two commands of the same type in a row, you don’t need to repeat the letter: `L1 2L-3 4` can become just `L1 2-3 4`; also, after the initial M or m command, it switches to L or l automatically, so in `M1 2L-3 4` the L could be removed.
An area I’d really like to see more work in (in SVG tooling in general) is path simplification/minification. In automated tools I’ve only seen rounding to a fixed number of decimal places, which is what this tool is offering, and which is terrible: some decimal places are far more significant than others, and indeed some points could be happily dropped, and rounding everything is not always the correct behaviour for fidelity. Instead of “two decimal places”, I’d like to see things like “accurate to within one pixel in any given direction”, which I reckon will normally compress better for a given quality level. There’s also the approach taken by Inkscape’s path simplification, which chooses a completely new set of points and curves that approximate the current values, but this harms the accuracy of the path and isn’t flexible enough (you run it in discrete steps, rather than there being a continuous slider or the ability to simplify some sections harder than others, whether automatically for best accuracy or manually).
- edent 6y agoIf you're interested in minifying SVGs by hand, we're creating SVG icons in under 1KB at https://github.com/edent/SuperTinyIcons/ https://github.com/edent/SuperTinyIcons/ We could do with some help on the accuracy of some of them :-)
- liquidise 6y agoAwesome project. So nice to see these logos collected in a place with attention to the underlying SVG detail. None of the garbage comments/ids/etc outputted by Adobe and Sketch.
- mawise 6y agoAwesome! One thing I noticed: your LinkedIn logo has an artifact when rendered small in my browser (Firefox). There is a thin vertical blue line between the downstroke and the round stroke in the 'n'.
- nyanpasu64 6y agoThe GitLab logo has very prominent gray lines between the segments. I recall reading an article about this issue with alpha blending, but can no longer find it. I found a related article: https://news.ycombinator.com/item?id=14310652 https://news.ycombinator.com/item?id=14310652
- nashashmi 6y agoAwesome project. I shamefully admit this is a hobby of mine as well. Glad to see I am not alone.
- dxxvi 6y agoThat is just ... wow! A tiny issue: you missed the Scala icon.
- edent 6y agoPlease send a pull request :-)
- pselbert 6y agoThat project is fantastic! I'll soon have need for some clean SVG language icons and these are perfect.
- tleb_ 6y agoHow do you recommend people send those to the front-end (assuming a web interface)? One request per icon as done in the README is extremely wasteful. Is there a format that allows importing multiple SVG in one request? Embedded at build time? Or as data URL? Not forgetting compression too as it makes a huge impact on big enough SVG: Firefox goes from 1024 (not 1023?) to 522 bytes, HN goes from 229 to 208.
- lima 6y ago> One request per icon as done in the README is extremely wasteful. That depends on the transport, this is one of the things that HTTP/2 (and HTTP/3) aim to fix by downloading them in parallel in a single connection. Watch the devtools network tab: http://www.http2demo.io/ http://www.http2demo.io/
- tleb_ 6y agoThere is still a header to send. Talking about SVG that are on average 465 bytes, a 867 bytes header (as sent by GitHub[0]) is not negligible. HTTP compresses headers though, so according to [1] we can expect ~30% header transferred size/actual size ratio which brings header transferred size to ~260 bytes. Still a 56% overhead for the average icon from this collection. [0]: https://camo.githubusercontent.com/d0518022b7a02d405ad5112a0c8aa455cbfe952e/68747470733a2f2f6564656e742e6769746875622e696f2f537570657254696e7949636f6e732f696d616765732f7376672f6769746875622e737667 https://camo.githubusercontent.com/d0518022b7a02d405ad5112a0... [1]: https://blog.cloudflare.com/hpack-the-silent-killer-feature-of-http-2/ https://blog.cloudflare.com/hpack-the-silent-killer-feature-...
- Hitton 6y agoIf it's more then couple svgs that repeat on every page and you want to use them as not just backgrounds (in which case I would recommend special .css file with svgs as data-uris), the best way is in my opinion storing them all in one file and then linking them using their id. It's described for instance in https://www.creativebloq.com/features/the-complete-guide-to-svg/6 https://www.creativebloq.com/features/the-complete-guide-to-...
- lenkite 6y agoHow do guys even manage to type those path coordinates by hand ? Do you do the calculations for path coordinates mentally ? Or use keep `calc` handy. Any Tips and Tricks would be appreciated.
- psadri 6y agoGoogle Maps path simplification aimed to minimize error between original and simplified paths. It’d prioritize dropping points that had the smallest impact on error.
- warpech 6y agoI can recommend path simplification tools built into https://github.com/Microsoft/maker.js https://github.com/Microsoft/maker.js Despite the repo description, it's a universally useful SVG library
- TimTheTinker 6y agoThanks for the very informative post! I wonder what you think about SVGOMG: https://jakearchibald.github.io/svgomg/ https://jakearchibald.github.io/svgomg/
- chrismorgan 6y agosvgo is one of the things that historically didn’t parse arc commands correctly, though if I recall correctly that’s been fixed for a couple of years now. svgo also has the terrible uniform-precision rounding technique. Beyond these things, well, I tend to use SVGOMG somewhere in my process of SVG optimisation. I like it.
- sbayeta 6y agoHi Chrismorgan, Could you please point me to some resource where the kind of abbreviation you show in the arc example are specified? I googled and couldn't find it. Thanks!
- chrismorgan 6y agoA couple of useful links: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d https://www.w3.org/TR/SVG11/paths.html#PathData https://www.w3.org/TR/SVG11/paths.html#PathData (SVG 1.1 spec) or https://svgwg.org/svg2-draft/paths.html#DProperty https://svgwg.org/svg2-draft/paths.html#DProperty (SVG 2 spec); the two are much of a muchness.
- swiley 6y agoThe few times I've needed a vector graphic quickly just typing an SVG into Vim always felt like the path of least resistance. (heh)
- ajfjrbfbf 6y agoTools that can't parse the compressed arc flags are especially frustrating. Android Studio for example.