Prevent devices from going into sleep while on a webpage

Imagine you’re following a recipe guide on your smartphone or tablet and having to unlock the device every time you need some information or want to go to the next step. Your hands are probably dirty, the device might be out of reach, or you have to bend over steaming boiling water.

It’s just one of the many examples where it could be interesting to offer a “no sleep” functionality to your visitors. The solution might be quite easier than expected. Github user richtr created a NoSleep.js module which allows you just to do so. The concept is pretty straightforward. When the “No Sleep” modus gets enabled a short video is injected into the page. The video itself has a white background and takes about 2 seconds. The script then constantly rewinds the video to a random point before the first half of the video. When disabled, the video gets paused.

It’s a clever usage from a basic functionality in modern smartphones and tablets, which don’t go into sleep mode while a video is playing.