Favicons have been around for a few years now. Â But they were mostly used by the browsers – in multi-tab environments and in bookmark managers. Â Recently I’ve noticed the trend to use favicons in web design – next to external links or near the blog comment’s author, etc.
Adding a favicon to the design is a simple thing for the designer. Â But a totally different story for the web developer. Â Favicons can be either dropped into the root folder of the site or linked to from the page’s HTML. Â On top of that, the times of the single favicon.ico format are long gone too. Â These days you could get a GIF or PNG image.
So, how would reliably finda favicon of a site? Â It turns out, you don’t really have to work too hard, since someone has already solved your problem. Â From comments to this article (in Russian) I’ve learned of the Google web service. Â So, all you’ll need to do is this (with whatever domain name that you need):
<img src="http://www.google.com/s2/favicons?domain=mamchenkov.net">
Works and sound good, right? Â Wrong! Â As I mentioned already, there is a way to link to favicons from HTML. Â And this service doesn’t seem to take that into account. Â Well, not to worry anyway. Â There is another one that does – getFavicon. Â This one works in a very similar way, but supports the full URL as a parameter. Â For example:
<img src="http://g.etfv.co/https://mamchenkov.net/wordpress/">
On top of that, you can include properly encoded GET parameters, and avoid browser’s per-server connection limit, by using multiple sub-domains. Â Brilliant, I say.