Lazy polyfill for wakelock API.
Last updated 5 months ago by henrikjoreteg .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install wakelock-lazy-polyfill 
SYNC missed versions from official npm registry.


npm i wakelock-lazy-polyfill

Polyfills WakeLock if not present by lazy-loading nosleep.js (but only when actually requested).

That means if it's natively supported this lib only adds ~800 bytes to your project.

Can also drop it in via CDN:

<script src="http://unpkg.com/wakelock-lazy-polyfill"></script>

Test site



The Web is getting a wonderful WakeLock API to keep your screen awake, but it's not broadly available yet. As of this writing it's a Origin Trial in Chrome that should ship in the next version.

Regardless, there's been a clever hack, called nosleep.js that plays a hidden video in the background to trick the browser into staying awake. This works pretty well, but...

  1. I want to use native version if available
  2. I only want to load the polyfill at the point where it's going to be used

So, here we are.




Obviously props to @richtr for nosleep.js and Thomas Steiner for his work on making the WakeLock API "A Thing".

If you like this, follow @HenrikJoreteg on twitter.

Current Tags

  • 1.0.0                                ...           latest (5 months ago)

1 Versions

  • 1.0.0                                ...           5 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
Dev Dependencies (2)
Dependents (0)

Copyright 2014 - 2017 © taobao.org |