Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update frequency for dynamic favicons

I wanted to learn how to dynamically update the favicon using the Google Chrome browser and I've noticed that the browser seems to throttle how often you can update the favicon per second and that sort of makes things look sloppy. The test page I've made for this is:

http://staticadmin.com/countdown.html

Which is simply a scrolling message displaying the results of a countdown. I added an input field to tweak how many pixels per second are moved by the script and I've eyeballed the max to be about 5 frames per second smoothly in Google Chrome and I have not tested it in any other browsers.

My question is what is the maximum frequency, are there any ways to change it, and is there a particular reason behind it?

NOTE: I've also noticed that this value changes based on window focus as well. It seems to drop to about 1 update per second when the browser's window isn't in focus and returns to "max" when you return.

like image 472
rfoo Avatar asked Aug 12 '14 06:08

rfoo


People also ask

How long does it take to update favicon?

It may take a few minutes to update, you may need to refresh the page (or clear your cache!) Having a favicon makes your brand look so much more professional. It doesn't really matter what it is, as long as you have one, and as long as it's not the Squarespace box!

Why is my favicon wrong?

Wrong dimensions, no favicon for you… Google has explained in detail that favicons must be a multiple of 48×48 pixels. So, make sure your favicon is at least 48×48 or a multiple of 48×48. For example, 96×96, 144×144, etc. Don't have a favicon that's smaller than 48×48.


1 Answers

The truth is, Chrome (and any reasonable browser) does not expect the favicon to ever change. They don't even show animations up there (only the first frame is frozen and displayed), though there's this feature request. The fact that you can change it at all through the DOM is somewhat of a hack. That's why the framerate is unpredictable, it's not even close to being optimized for that.

Chrome (and other browsers) throttle setInterval and friends to 1 Hz when the tab is blurred, which is why the animation becomes even worse when you switch tabs. It doesn't know that your interval is acting on a currently visible UI element.

There is no way to change this behavior, nor the maximum frequency, through JavaScript. Sorry.

like image 51
rvighne Avatar answered Oct 02 '22 15:10

rvighne