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 ...)
}
}
Written by Valentin Beuret
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Js
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#