[whatwg] window.setInterval if visible.

João Eiras joaoe at opera.com
Thu Oct 15 13:02:32 PDT 2009


On Thu, 15 Oct 2009 21:35:03 +0200, Gregg Tavares <gman at google.com> wrote:

> I was wondering if there as been a proposal for either an optional  
> argument
> to setInterval that makes it only callback if the window is visible OR  
> maybe
> a window.setRenderInterval.

You're trying to solve a real problem with a very specific API. You might  
use setInterval, but someone else might use a worker or setTimeout.

The best way would be an attribute on the window, like window.isVisible  
returning either true of false which would return true if the document is  
partially or totally visible.
This way, all other possible use cases to prevent animations or other  
complex and heavy dom/layout operations could be postponed just by  
checking that value.

I personally think it's a good idea to have that info available.



More information about the whatwg mailing list