Skip to content
Prevent display sleep and enable wake lock in any Android or iOS web browser.
JavaScript HTML
Find file
Latest commit 55635cb @richtr Merge pull request #5 from CurtisHumphrey/master
Updated the url used for iOS NoSleep.js to work for more use cases

README.md

NoSleep.js

Prevent display sleep and enable wake lock in all Android and iOS web browsers.

Check out the live demo in any Android or iOS web browser.

Installation

This library is available on Bower as nosleep.

$> bower install nosleep

Alternatively, you can manually add NoSleep.js to your project (or the minified version).

Usage

Create a new NoSleep object and then enable or disable it when needed as follows:

var noSleep = new NoSleep();

function enableNoSleep() {
  noSleep.enable();
  document.removeEventListener('touchstart', enableNoSleep, false);
}

// Enable wake lock.
// (must be wrapped in a user input event handler e.g. a mouse or touch handler)
document.addEventListener('touchstart', enableNoSleep, false);

// ...

// Disable wake lock at some point in the future.
// (does not need to be wrapped in any user input event handler)
noSleep.disable();

License

MIT. Copyright (c) Rich Tibbett

Something went wrong with that request. Please try again.