Isn't it silly that a tiny favicon requires yet another HTTP request? How can I put the favicon into a sprite?

后端 未结 14 1825
暖寄归人
暖寄归人 2020-11-29 14:58

Everybody knows how to set up a favicon.ico link in HTML:



        
14条回答
  •  鱼传尺愫
    2020-11-29 15:21

    You can use 8-bit PNG instead of ICO format for even smaller data footprint. Only thing you have to change is using "data:image/png" instead of "data:image/x-icon" MIME type header:

    
    

    "type" attribute can be "image/png" or "image/x-icon", both works for me.

    You can convert ICO to 8-bit png using gimp or convert:

    convert favicon.ico -depth 8 -strip favicon.png
    

    and encode PNG binary to base64 string using base64 command:

    base64 favicon.png
    

提交回复
热议问题