Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent favicon.ico requests?

Tags:

favicon

I don't have a favicon.ico, but my browser always makes a request for it.

Is it possible to prevent the browser from making a request for the favicon from my site? Maybe some META-TAG in the HTML header?

like image 988
Daniel Silveira Avatar asked Aug 24 '09 11:08

Daniel Silveira


People also ask

What is Cannot get favicon ICO?

Try placing the ico file in an images folder in your root. That's where many browsers look for favicon. And that's something to keep in mind. Favicon is a very loose standard, if you can even call it that, which is supported by browsers, not by the server.

How do I remove favicon from website?

By default, your browser will use the favicon in the same folder with your html file, so removing your link tag will do nothing. You need to move the favicon elsewhere or delete it. Then, if it stills shows up, clear your cache and go to the icon to see the new one.

How do I remove favicon from Chrome?

Right click at your bookmark; the popup menu with option "Change Favicon", "Reset Favicon", "Remove Favicon" and "Export Favicon" will appear. You can use any image file or any image URL that browser support as a favicon.


1 Answers

I will first say that having a favicon in a Web page is a good thing (normally).

However it is not always desired and sometime developers need a way to avoid the extra payload. For example an IFRAME would request a favicon without showing it. Worst yet, in Chrome and Android an IFRAME will generate 3 requests for favicons:

"GET /favicon.ico HTTP/1.1" 404 183 "GET /apple-touch-icon-precomposed.png HTTP/1.1" 404 197 "GET /apple-touch-icon.png HTTP/1.1" 404 189 

The following uses data URI and can be used to avoid fake favicon requests:

<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon">  

For references see here:

  • https://github.com/h5bp/html5-boilerplate/issues/1103
  • https://twitter.com/diegoperini/status/4882543836930048

UPDATE 1:

From the comments (jpic) it looks like Firefox >= 25 doesn't like the above syntax anymore. I tested on Firefox 27 and it doesn't work while it still work on Webkit/Chrome.

So here is the new one that should cover all recent browsers. I tested Safari, Chrome and Firefox:

<link rel="icon" href="data:;base64,="> 

I left out the "shortcut" name from the "rel" attribute value since that's only for older IE and versions of IE < 8 doesn't like dataURIs either. Not tested on IE8.

UPDATE 2:

If you need your document to validate against HTML5 use this instead:

<link rel="icon" href="data:;base64,iVBORw0KGgo="> 
like image 169
Diego Perini Avatar answered Sep 23 '22 08:09

Diego Perini