How do I detect if a browser page is in a visible browser tab or not, using javascript or jquery?
I want to avoid doing some costly calculations and server requests in cases where the user will not see the results anyway. Also, is there some better way of doing this other than trying to detect if the tab is in the background?