top | item 37748507 Show HN: Zany – Favicon API 30 points| jchap | 2 years ago |zany.sh Got mad at this console error the other night: "Failed to load resource: the server responded with a status of 404 (File not found) :8000/favicon.ico:1" and hacked this together. Never have to worry about that 16x16 square again. 11 comments order hn newest modec|2 years ago Or you can get a emoji as favicon with:<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>FAVORITE EMOJI HERE</text></svg>"> myfonj|2 years ago Yup. My last "golfing" take was to use default font-size and fit viewBox accordingly: data:text/html;charset=utf-8,<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text>%F0%9F%A6%84</text></svg>'> But haven't tested outside Windows, so it will be most probably off in some browsers (Safari?).Or this funky quine document with same unicorn emoji that rotates or fades depending on prefers-reduced-motion: data:text/html;charset=utf-8,<!doctype html>%0A<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text transform-origin="10 -3">%F0%9F%A6%84</text><style>@keyframes x{to{transform:rotate(1turn)}}@keyframes y{to{opacity:0}}text{animation:2s x infinite alternate}@media(prefers-reduced-motion){text{animation-name:y}}</style></svg>'>%0A<title>Animated favicon affected by `prefers-reduced-motion` media query, embedded in datauri inside datauri document</title>%0A<style>:not(style,script){display:block; padding:0 .2em; background:darkslategray; color:snow; white-space:pre-wrap} title::after{content:' (in `' var(--prm) '` mode)'}html{--prm:'no-preference'}@media(prefers-reduced-motion:reduce){html{--prm:'reduce'}}</style>%0A<script>document.write('<plaintext>',decodeURIComponent(document.URL))</script> Etheryte|2 years ago As an alternative approach you can use an empty data URL to get an empty favicon: <link rel="icon" type="image/svg+xml" href="data:image/svg+xml," /> melx|2 years ago or just "ignore" the favicon altogether: <link rel="icon" href="data:," /> load replies (1) smartis2812|2 years ago And its dependency free - Nice!Thank you myfonj|2 years ago You can make folks test it in their browsers by instructing them to copy and paste dataURI into their URL bar, like: data:text/html,<link rel="icon" href="https://zany.sh/favicon.svg?text=hi"> This one for example shows nearly invisible text in dark theme for me.Or maybe add text input to dynamically update current page's favicon to see the outcome instantly. jchap|2 years ago this is a great idea, going to update the docs. also, regarding dark themes, you can control the text/background color via query params: <link rel="icon" href="https://zany.sh/favicon.svg?text=hi&background-color=black&text-color=white"> mthoms|2 years ago Is this open source? jchap|2 years ago it is not, just a simple hosted service runnr_az|2 years ago Clever!
modec|2 years ago Or you can get a emoji as favicon with:<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>FAVORITE EMOJI HERE</text></svg>"> myfonj|2 years ago Yup. My last "golfing" take was to use default font-size and fit viewBox accordingly: data:text/html;charset=utf-8,<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text>%F0%9F%A6%84</text></svg>'> But haven't tested outside Windows, so it will be most probably off in some browsers (Safari?).Or this funky quine document with same unicorn emoji that rotates or fades depending on prefers-reduced-motion: data:text/html;charset=utf-8,<!doctype html>%0A<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text transform-origin="10 -3">%F0%9F%A6%84</text><style>@keyframes x{to{transform:rotate(1turn)}}@keyframes y{to{opacity:0}}text{animation:2s x infinite alternate}@media(prefers-reduced-motion){text{animation-name:y}}</style></svg>'>%0A<title>Animated favicon affected by `prefers-reduced-motion` media query, embedded in datauri inside datauri document</title>%0A<style>:not(style,script){display:block; padding:0 .2em; background:darkslategray; color:snow; white-space:pre-wrap} title::after{content:' (in `' var(--prm) '` mode)'}html{--prm:'no-preference'}@media(prefers-reduced-motion:reduce){html{--prm:'reduce'}}</style>%0A<script>document.write('<plaintext>',decodeURIComponent(document.URL))</script>
myfonj|2 years ago Yup. My last "golfing" take was to use default font-size and fit viewBox accordingly: data:text/html;charset=utf-8,<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text>%F0%9F%A6%84</text></svg>'> But haven't tested outside Windows, so it will be most probably off in some browsers (Safari?).Or this funky quine document with same unicorn emoji that rotates or fades depending on prefers-reduced-motion: data:text/html;charset=utf-8,<!doctype html>%0A<link rel=icon href='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="1,-15,19,19"><text transform-origin="10 -3">%F0%9F%A6%84</text><style>@keyframes x{to{transform:rotate(1turn)}}@keyframes y{to{opacity:0}}text{animation:2s x infinite alternate}@media(prefers-reduced-motion){text{animation-name:y}}</style></svg>'>%0A<title>Animated favicon affected by `prefers-reduced-motion` media query, embedded in datauri inside datauri document</title>%0A<style>:not(style,script){display:block; padding:0 .2em; background:darkslategray; color:snow; white-space:pre-wrap} title::after{content:' (in `' var(--prm) '` mode)'}html{--prm:'no-preference'}@media(prefers-reduced-motion:reduce){html{--prm:'reduce'}}</style>%0A<script>document.write('<plaintext>',decodeURIComponent(document.URL))</script>
Etheryte|2 years ago As an alternative approach you can use an empty data URL to get an empty favicon: <link rel="icon" type="image/svg+xml" href="data:image/svg+xml," /> melx|2 years ago or just "ignore" the favicon altogether: <link rel="icon" href="data:," /> load replies (1) smartis2812|2 years ago And its dependency free - Nice!Thank you
melx|2 years ago or just "ignore" the favicon altogether: <link rel="icon" href="data:," /> load replies (1)
myfonj|2 years ago You can make folks test it in their browsers by instructing them to copy and paste dataURI into their URL bar, like: data:text/html,<link rel="icon" href="https://zany.sh/favicon.svg?text=hi"> This one for example shows nearly invisible text in dark theme for me.Or maybe add text input to dynamically update current page's favicon to see the outcome instantly. jchap|2 years ago this is a great idea, going to update the docs. also, regarding dark themes, you can control the text/background color via query params: <link rel="icon" href="https://zany.sh/favicon.svg?text=hi&background-color=black&text-color=white">
jchap|2 years ago this is a great idea, going to update the docs. also, regarding dark themes, you can control the text/background color via query params: <link rel="icon" href="https://zany.sh/favicon.svg?text=hi&background-color=black&text-color=white">
modec|2 years ago
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>FAVORITE EMOJI HERE</text></svg>">
myfonj|2 years ago
Or this funky quine document with same unicorn emoji that rotates or fades depending on prefers-reduced-motion:
Etheryte|2 years ago
melx|2 years ago
smartis2812|2 years ago
Thank you
myfonj|2 years ago
Or maybe add text input to dynamically update current page's favicon to see the outcome instantly.
jchap|2 years ago
mthoms|2 years ago
jchap|2 years ago
runnr_az|2 years ago