I've been hanging around in the jQuery IRC-Channel today, when somebody came in and asked a simple question:
<simulation> how can i know if the page is on visible tab or passive tab ?
At first I thought this'd be impossible. Neither I there an API that I know of, nor should it be possible because of privacy. (Note: There are Fx internal APIs like tabs.focused
)
Thankfully recently Browser vendors added the requestAnimationFrame function. We can use that to hack something together.
load the reqAF-shim: https://gist.github.com/997619 and save it to any variable, eg reqAF.
you have enough space, why not cache the
requestAnimationFrame
function instead of having to pass it?(or at least make passing it optional)