Hacker News new | ask | show | jobs
by arcameron 3823 days ago
Regarding the avatar images:

Why not a <div> with a border-radius & background color? Seems you could achieve the same thing without another HTTP request (1 for each unique avatar), no need to zopfli 45,000 unique files.

5 comments

That's what I was thinking too, but they really want it to be pixel perfect in every browser, email, etc. They have a good in-depth discussion about all the options and pros/cons of each approach here:

https://meta.discourse.org/t/optimizing-letter-avatar-render...

These are default (placeholder) avatars. Users can upload their own avatar image as well. They're serving PNGs so they don't have to deal with the case where users using default avatars get HTML output whereas users who have uploaded an avatar get an image inserted.
Also font and alignment issues cross browser can be brutal. There is a lot to be said for a tiny image that works everywhere, on any device.
What about an svg?
That wont work in email... I'm generating a usage graph (svg) that is emailed and the graph will not display in the client.. Must be opened in a browser
Seems like you could use an SVG avatar for clients that can handle it and fallback to PNG for email.
See the comments: lots of tweaking and unreliability and not guaranteed to work in emails, apparently.
I was confused by this as well, you could also support more colors this way. Since it's just a circle with a letter, I don't think there would be concerns with crispness of the icon.