No favicon
Web browsers really like favicons. If your site does not declare one with
<link rel="icon">
, most (all?) of the mainstream ones will issue request to
/favicon.ico
anyway, in a hope of getting one.
Favicons are a whole topic on its own. But what if we don't use one? Can we somehow nudge browsers towards actually not looking for it? For saving them from making an extra request and for making dev tools and server logs less noisy from all those 404s.
Yes. Data urls to the rescue. They allow us to inline contents directly within the page source. Caniuse reports 97% coverage and MDN marks them in their baseline classification as "Widely available".
The syntax is data:[<media-type>][;base64],<data>
. Here we use data url to inline an empty string:
<link rel="icon" href="data:," />
In principle this should make supporting browsers to behave as if we served an empty
file from remote host. From my short experiments I can see this works fine (meaning:
no favicons request) with Firefox, Chromium and Chrome. On mobile Safari
I've caught single requests here and there despite the above link
, so not sure.
Any potential issues coming from the above approach (like browser fetching remote file despite data url) may be related not to the data scheme usage itself, but to the embedding of an empty string. Inlining an actual small "empty" image could maybe improve the effect in some cases. Although, arguably, this starts being close to... just having an actual favicon.