Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML header link - When are these elements loaded?

Tags:

html

favicon

I am working on a new web project and currently I am using the favicon files. Some time ago this was an easy task but nowadays almost the complete HTML header seems to be occupied by this topic:

  • Default favicon
  • iOS favicon
  • Microsoft favicon and tiles
  • Android favicon
  • Safari tabs icons
  • Chrome icons
  • ...

All these elements are referenced using the standard <link /> tag. I now wonder when these elements are loaded:

Are all <link /> elements loaded by default or are the different browsers smart enough to only load such elements that are really used on the current platform/system? So is the Windows Tile Icon loaded on iOS as well?

The same is true for other elements that are referenced as <link />? Assume that there are 100 different style sheets linked in the header. Theoretically the browser could load these files in reverse order (later styles override earlier once). If all styles that are used in the current file are already defined in the last style sheet there is not need to load the other 99 files, is it?

Most likely in real life it is much harder to determine if a style sheet handles all possible stlyes than downloading and parsing/combining all 100 files.

However the question is the same: It seems that there are many cases when it is not necessary to download all <link /> elements. Are browsers smart enough to detect and use these cases?

like image 605
Andrei Herford Avatar asked Sep 19 '25 02:09

Andrei Herford


2 Answers

Nowadays, you should declare at least 3 or 4 icons to support all browsers, and up to 20+ icons if you want to implement the full range of available icons. There are known issues regarding loading:

  • Firefox loads all PNG icons on the critical path (the link rel="icon" icons; not the Apple touch icons). The root cause is that FF does not support the sizes attribute. If you feel concerned by this, please vote for this bug.
  • Chrome loads more than one PNG icon, which is better than what it used to be, but still not perfect. Same root cause: Chromes does not support the sizes attribute. But apparently the Chromium team feels concerned about this.
  • iOS Safari often loads two different Touch icons. This is something I observed several times in server logs while testing icons with an iPad, but I don't have any solid material to provide here. Also note that iOS Safari regularly loads Touch icons in the root path by convention (for example, /apple-touch-icon-120x120-precomposed.png). So declaring less Touch icons, or even only one Touch icon, may not be a definitive solution: Safari may try to load some icons nonetheless and get 404s.

I have no data for Android Chrome or IE.

like image 151
philippe_b Avatar answered Sep 20 '25 18:09

philippe_b


Assuming the response from:

How to prevent favicon.ico requests?

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

And from: Will browsers request /favicon.ico or <link> first?

I guess that the browsers requests all the favicons in the <link> first, if no specified, then search for 'favicon' in the root of the folder.

FYI: You can take a look at: https://github.com/audreyr/favicon-cheat-sheet too to get more info! Hope it helps!

like image 29
JP. Aulet Avatar answered Sep 20 '25 18:09

JP. Aulet