开发者

Any problems with favicons in a subfolder?

开发者 https://www.devze.com 2023-02-16 01:18 出处:网络
Could there be any problems moving favicons and apple touch icons to a subfolder? Like: <link rel=\"shortcut icon\" href=\"/images/favicons/favicon.ico\">

Could there be any problems moving favicons and apple touch icons to a subfolder? Like:

<link rel="shortcut icon" href="/images/favicons/favicon.ico">
&l开发者_Go百科t;link rel="apple-touch-icon" href="/images/favicons/apple-touch-icon.png">


Yes, some browsers start downloading /favicon.ico at the same time they start downloading HTML document. If there's no file you'll get an extra 404 in your server log and the browser will have to make an extra HTTP request when it recognizes the icon is elsewhere.

A quote from Yahoo's Best Practices for Speeding Up Your Web Site:

The favicon.ico is an image that stays in the root of your server. It's a necessary evil because even if you don't care about it the browser will still request it, so it's better not to respond with a 404 Not Found. Also since it's on the same server, cookies are sent every time it's requested. This image also interferes with the download sequence, for example in IE when you request extra components in the onload, the favicon will be downloaded before these extra components.


The only problem could be that your relative link is not under the root domain, so that

HOST / YourPath /images/favicon.ico

can be found difficult.

If that would be the case then you would need to include a base href tag in your document and then this would be solved.

p.s. here is the parser i'm writing now to auto download favicons, find yourself in the flow: http://plugins.trac.wordpress.org/browser/wp-favicons/trunk/includes/class-http.php

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号