Last Updated: February 25, 2016
·
1.025K
· beuretv

Is your document.hidden ?

When you change tabs, videos (for example) do not stop, so slow down your browser.

solution: pause automatically if the element is not visible to the user.

hidden : not visible
visible : display
prerender : download the element offscreen
unloaded : wait the mémory

for do this, you must add an event listener.
the document[hidden] is a minimal configuration, use the -prefixHidden for target browser.

// type, listener, useCapture
document.addEventListener('visibilitychange', hidden, false);

function hidden(){

    if(document[hidden]) {
            //your action ... (pause your animation or other)
} else {
            //your action ... (play ...)
}

}