Hacker News new | ask | show | jobs
by im3w1l 1525 days ago
The png is only 103 bytes though. Btw your svg can be decreased by changing viewBox to 0 0 1 1, and also by changing the path to a circle (implicitly positioned at 0, 0)

  <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 1 1"><circle r="2" fill="#aad3df"/></svg>
3 comments

Depending on how you're loading the svg in the page the xmlns attribute may not be needed as well.
The SVG could also be served with gzip compression.

  >>> len('<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256"><path d="M0 0h256v256H0z" fill="#aad3df"/></svg>'.encode('zip'))
  122
Gzipping doesn't save much.
brotli helps:

  $ echo '<svg xmlns="http://www.w3.org/2000/svg" height="256" width="256" viewBox="0 0 1 1"><circle r="2" fill="#aad3df"/></svg>' | brotli -9 - | wc -c
  93
Couldn't resist trying to go further. We can use an implicit viewBox.

  $ echo '<svg xmlns="http://www.w3.org/2000/svg" height="256" width="256"><circle r="1000" fill="#aad3df"/></svg>' | brotli -9 - | wc -c
  83
r="1000" hits brotlis built-in dictionary, but if you target zlib then r="2566" is better.
You can also drop the new line character by using echo -n, which gives 82 bytes :)
Can you use a short closing tag "</>" or implicit closure?
Those are both sgml (as opposed to xml) things. Neither validates.
Doesn't the SVG scale better? I sure hope so.
For a single color? I don't think it really matters. It's all inherently lossless.
For a solid color block it doesn't really matter. For the rest of the map sure, Google Maps in normal mode (instead of classic as in the article) is vector rendering based.