Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/henrikjoreteg/wakelock-lazy-polyfill
Use nosleep.js as a lazy-loaded polyfill for WakeLock API
https://github.com/henrikjoreteg/wakelock-lazy-polyfill
polyfill wakelock web
Last synced: 3 days ago
JSON representation
Use nosleep.js as a lazy-loaded polyfill for WakeLock API
- Host: GitHub
- URL: https://github.com/henrikjoreteg/wakelock-lazy-polyfill
- Owner: HenrikJoreteg
- Created: 2020-06-18T14:28:05.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T09:18:08.000Z (almost 2 years ago)
- Last Synced: 2024-10-07T08:16:36.275Z (about 1 month ago)
- Topics: polyfill, wakelock, web
- Language: JavaScript
- Homepage: https://wakelock-polyfill.joreteg.com/
- Size: 1.16 MB
- Stars: 7
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wakelock-lazy-polyfill
```bash
npm i wakelock-lazy-polyfill
```Polyfills WakeLock if not present by lazy-loading [nosleep.js](https://github.com/richtr/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:
```html
```
## Test site
https://wakelock-polyfill.joreteg.com/
## Background
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 usedSo, here we are.
## License
[MIT](https://mit.joreteg.com/)
## Credits
Obviously props to [@richtr](https://github.com/richtr) for nosleep.js and [Thomas Steiner](https://twitter.com/tomayac) for his work on making the WakeLock API "A Thing".
If you like this, follow [@HenrikJoreteg](https://twitter.com/HenrikJoreteg) on twitter.