Our project uses a variety of libraries (Kinetic Js, jquery, buzz.js, etc..), we have a lot of animations going on and some sounds playing simultaneously ,our purpose is stop all the JavaScript processes when a user change the tab or the window of the browser, losing focus.
We know that the onBlur and onFocus gives us the ability to detect that change and with one setTimeOut function we can stop it. We want to know if there is a more efective way of doing that or a more low level solution.
Thanks in advance.
These days, there’s requestAnimationFrame() http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/RequestAnimationFrame/Overview.html
Article with info about browser support, and how to emulate in browsers that do not support it: http://paulirish.com/2011/requestanimationframe-for-smart-animating/.