How to avoid loading a favicon?

Asked

Viewed 117 times

2

I have a site in wordpress, the problem is that it pulls the site favicon somewhere that I can not find, I checked in all the files of the site and found nothing written favicon, I want to remove this file from the html favicon code in the code because it’s giving me 400 ms more loading.

Does anyone know where I can find this creep of his using any tools? I’ve already used this google Chrome and I can’t find,inspected element and I can’t find anything either.

inserir a descrição da imagem aqui

I found in wordpress includes/load.php the favicon generation function:

function wp_favicon_request() {
    if ( '/favicon.ico' == $_SERVER['REQUEST_URI'] ) {
        header( 'Content-Type: image/vnd.microsoft.icon' );
        exit;
    }
}

Does anyone know where wordpress pulls this function in wordpress?

1 answer

5


If there is nothing on the page that actually requests the "favicon", your browser will end up ordering a "on its own", which will not solve the problem.

One way to avoid this behavior (which is not guaranteed to work always and in all browsers) is to provide a "fake favicon" this way, within the <head>:

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

The same technique can be used to "embed" some icon on the page itself, but there it can be more expensive yet, because it will not be "curly" and will cost in any request.

The best thing would be to actually provide a favicon, but with cache headers so that it is stored in the browser at the first access, and stay there for at least a few days, since it is something that is not left changing at all times.

If you want a transparent GIF instead of an invalid icon, follow the data-url:

 <link rel="shortcut icon"
  href="data:image/gif;base64,R0lGODlhAQABAIAAA///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
  type="image/gif">


About the mentioned WP function, it does not require the favicon, it is triggered if one is requested. In this case, the above tag should even prevent the function from being called.

  • It worked, the favicon is no longer being called on my site, nor appears on the network, my score on gtmetrix was A 100% . thanks

  • I’m glad it worked out. But remember, more important than the score, it’s the user experience. Consider the possibility of putting a real favicon and making it cache.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.