News for hackers. Stuff that matters.
Re:Show HN: Emojicons by chrismorgan on Saturday April 24, 2021 @04:39AM (#26923345)
It would be good to change this:

  new Blob([svgText], {type: 'text/svg'});
To this:

  new File([svgText], 'favicon.svg', {type: 'image/svg+xml; charset=utf-8'})
This gives it a filename, restores the correct MIME type, and resolves possible encoding issues. By restoring the correct MIME type, the browser will now probably actually open it, so you may then want to mess around with an <a download> solution to trigger downloading instead of opening, but I’ll skip the implementation details of that.

In the end I’d actually go with a data: URI rather than a blob. <a download=favicon.svg href=data:image/svg+xml,…> works fine. And then it raises the question of just inlining the whole icon instead of keeping favicon.svg separate, as demonstrated by mfontani.

There are no comments on this comment yet.