Reputation: 1198
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.
Upvotes: 7
Views: 388
Reputation: 21887
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.
Upvotes: 2