Visibility.js is a nice-looking javascript wrapper for the Page Visibility API that also provides high-level timers and initialisers that take page visibility into account.
https://github.com/ai/visibility.js
These are techniques which all javascript-heavy websites should start employing imho. There's no reason why every browser tab you have open should be consuming CPU cycles when they're not visible. If you add them all together for everyone on the planet, it would probably equate to a lot of global warming!