You can just hope that /favicon.ico works. But 1. it often doesn’t and 2. it is often of low quality.
To find a favicon on a modern site you need to load the HTML and check Link headers and <linkrel=icon> elements. However you likely can’t do this client-side for most sites because of CORS. So you need some server (at the very least to strip CORS). That lets you get the URL but 1. you probably don’t want to have connections to external domains for user privacy and 2. some domains will have hot-link protection so you need to fetch the image via your server. You will also want to consider different image formats and sizes to serve the right image to the right client. On top of all of this the site may be using some sort of bot protection which you will have to fight. Google is almost always whitelisted. The site may also have temporary outages so having a cache would be nice, especially if that is almost always populated before you even know the domain exists.
At the end of the day you do want some sort of API. And while it isn’t complex it isn’t trivial. So it is nice to just let Google handle it. (Other than tracking risks, but you could proxy Google’s API.)
Hmm, all of those are fair points. I guess I was just thinking this seems like an overengineered solution to a niche problem, but I suppose for the people who actually have that problem, the solution is good to have.
No, favicons are usually encrypted and not publically visible. You have to connect your website to the google favicon service for it to be shown to users. /s
So does the website itself, though, right?
Sort of…
You can just hope that
/favicon.ico
works. But 1. it often doesn’t and 2. it is often of low quality.To find a favicon on a modern site you need to load the HTML and check
Link
headers and<link rel=icon>
elements. However you likely can’t do this client-side for most sites because of CORS. So you need some server (at the very least to strip CORS). That lets you get the URL but 1. you probably don’t want to have connections to external domains for user privacy and 2. some domains will have hot-link protection so you need to fetch the image via your server. You will also want to consider different image formats and sizes to serve the right image to the right client. On top of all of this the site may be using some sort of bot protection which you will have to fight. Google is almost always whitelisted. The site may also have temporary outages so having a cache would be nice, especially if that is almost always populated before you even know the domain exists.At the end of the day you do want some sort of API. And while it isn’t complex it isn’t trivial. So it is nice to just let Google handle it. (Other than tracking risks, but you could proxy Google’s API.)
Hmm, all of those are fair points. I guess I was just thinking this seems like an overengineered solution to a niche problem, but I suppose for the people who actually have that problem, the solution is good to have.
I know that KeepassXC has an automatic favicon downloader built-in and it’s open source. Maybe check out it’s code.
No, favicons are usually encrypted and not publically visible. You have to connect your website to the google favicon service for it to be shown to users. /s
Last night, somewhere in Mountain View, Sundar Pichai sat bolt upright in bed, realizing that there was a possible profit center yet untapped…