Odd issue with favicon.ico

January 16th, 2010 | by bryan |

Awhile ago, I added a feature that would try and add the favicon.ico for a site next to its feed name. Most sites have this image in a common location at http://www.site.com/favicon.ico. It’s also possible to set another location with a tag in the head of the html page.  Since I didn’t feel that it was critical to have this, just a nice to have, I added in the img tags with an onError handler that would hide the image if it wasn’t in the default location.

These images created a bit of an issue though. Several sites would serve a large 404 page with ads and everything if the favicon wasn’t in the default location. The ReadPath page would do the correct thing and hide the image, but behind the scenes it turns out that the browser could do quite a bit of excessive downloading if the 404 pages were too large. Instead of loading a minimal 16 x 16px image it could end up loading a huge 404 page. With 20 stories on the page it’s possible to load up a whole lot of things that will never be displayed and just bog down the browser.

I’ve since changed the behavior so that the favicon images are only loaded after the page itself has finished loading. This should cure the speed issues, but still leaves the possibility of the browser loading a lot of things that aren’t necessary. I thought about caching a copy of the image and keeping a flag on whether the image existed, this would sidestep all of the performance issues, but creates all sorts of other issues. So for the time being I’ll leave it with the delayed load.

 
 
 
 

Post a Comment