Reputation: 116293
I have modified this jQuery pluggin to make a table that updates with an animation every second. I have a bug in my code whereby a JavaScript error occurs each time the window looses focus. (The error is that a certain transient DOM element for the animation is not in the page, when it should actually be there.)
I have a strong feeling that this is due to the way browsers slow down setTimeout
s (in my case, probably inside jQuery.animate()
) on tabs that do not have focus, for performance reasons.
How can I avoid my JavaScript from breaking down when the window containing it looses focus?
Upvotes: 0
Views: 175
Reputation: 7471
Before executing your code triggered by the timer you have to check whether the previous execution is finished.
Upvotes: 1