Socket
Socket
Sign inDemoInstall

wakelock-lazy-polyfill

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

wakelock-lazy-polyfill


Version published
Maintainers
1
Install size
8.99 kB
Created

Readme

Source

wakelock-lazy-polyfill

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

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 used

So, here we are.

License

MIT

Credits

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.

FAQs

Last updated on 18 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc