Book Image

Mastering jQuery

By : Alex Libby
Book Image

Mastering jQuery

By: Alex Libby

Overview of this book

<p>Mastering jQuery has been written not only to help maximize your skills with core functionality in the library, but also to explore some of the more intriguing ways of using the library to achieve real-world solutions that could feature on any website or online environment.</p> <p>You'll start with a look at some of the more advanced ways to incorporate the library into your pages, followed by working with forms and advanced form validation using regular expressions. Next you'll move on to animating in jQuery, advanced event handling, and using jQuery effects.</p> <p>Finally, you will develop practical examples of using jQuery with external functionality such as node-webkit, before finishing with a session on optimizing your version of the library for maximum efficiency and exploring best practices for using QUnit.</p>
Table of Contents (21 chapters)
Mastering jQuery
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

An introduction to the Page Visibility API


Consider this scenario for a moment, if you will:

You're viewing a content-heavy site on an iPad, which is set to pre-render content. This is beginning to hammer the resources on the device, with the result that battery power is being drained quickly. Can you do anything about it? Well, on that site, probably not – but if it is a site you own, then yes. Welcome to the Page Visibility API.

The Page Visibility API is a nifty little API that detects when content in a browser tab is visible (that is, being viewed), or hidden. Why is this of interest? Simple – if a browser tab is hidden, then there is no point in playing media on the site, or running frequent polls to a service, right?

The net impact of using this API is aimed at reducing the use of resources and (consequently) saving power. After all, your visitors will not thank you if their batteries are drained as a result of visiting a media-heavy site!

Over the next few pages, we're going to visit...