HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
richtr
NoSleep.js
JavaScript2015–2025
richtr / NoSleep.js

NoSleep.js

Prevent display sleep and enable wake lock in any Android or iOS web browser.

6Distinct people
8Mentions
0Explicit recommenders
2.4KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Prevent display sleep and enable wake lock in any Android or iOS web browser.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year8 dated mentions

Observed mentions: 2015-04-21 08:39:36 UTC to 2025-01-29 09:35:48 UTC.

01232015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC110
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC000
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC000
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC000
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC000
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC202
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC312
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC101

What Hacker News says

8 sources
Indeed. I work on the Firefox media stack and we have been grabbing wake locks when video playback is happening for a long time. Occasionally e.g. on some linux desktop variant this has malfunctioned and we're alerted in no time and fix it. The Wake Lock API is for other use cases, such as recipe websites, or other document for which you don't want the screen to go away / dim, the kind where you happen to need to look at the screen for long period of time without touching it/interacting w/ mouse and keyboard. Prior to this API being introduced, websites used to play an inaudible/almost invisible looping media file to keep the screen awake. This has power usage implication, a small single digit number of watts (1 to 3.5 depending on os, hardware, mobile or not) is required to keep audio running (because of high priority threads, frequent w
Read the rest
akeups, and simply because the audio hardware itself needs power). One of those libraries source, for illustration: https://github.com/richtr/NoSleep.js/blob/master/src/index.j...
In New speculative attacks on Apple CPUs
Awesome project! Reminds me of donothingfor2minutes.com from Calm, but with a different end goal of focus instead of calm. Regarding mobile phones going to sleep, Wake lock [1] might help, unless you can reduce to 59s since I believe 1m is the threshold (make sure to request within the context of the user hitting "start"). Unfortunately on older mobile browsers [2], the best workaround I found was using this NoSleep library[3]. Source: ran into this same issue when building https://www.phonefreehour.com [1] https://developer.mozilla.org/en-US/docs/Web/API/WakeLock [2] https://caniuse.com/wake-lock [3] https://github.com/richtr/NoSleep.js
In Show HN: Improve cognitive focus in 1 minute
dtran·Aug 24, 2023Submission

Show HN: A simple web app to combat phone addiction

When I'm stuck on coding something, I find myself reaching for my phone even if I don't have any particular reason to do so. Inspired by Calm's DoNothingFor2Minutes.com which launched on HN 13 years ago [1], I made this simple webapp to see if my friends and I could go an hour without touching our phones. It is surprisingly difficult. According to a 2022 survey [2], the average US adult picks up their phone 352 times per day, or approximately once every 2m43s while they're awake. On browsers that support it (iOS 16.4+, most versions of Android Chrome), it uses the Screen Wake Lock API [3] to keep the page open, and falls back to nosleep.js [4] otherwise. From testing on my iPhone 14 Pro Max running iOS 16.6, battery life only went down 3 or 4 percentage points after an hour with the wake lock. Made this as a web app as a quick demo to be
Read the rest
compatible across all mobile devices. As an app, we can probably save more on battery + not have the screen on. One caveat is that on iOS this will actually increase your Screen Time (although hopefully reduce your other category usage). I currently only track time on page through Google Analytics 4. No other calls are made to a server, although if we actually wanted to verify that you kept the page open vs. javascript/inspector-system clock-fu, we could add a verified mode that pings the server every X minutes. As a PWA, possibly due to an iOS/Mobile Safari quirk/bug [5], neither wake lock nor nosleep.js appear to work . [1] https://news.ycombinator.com/item?id=2124106 [2] https://www.asurion.com/connect/news/tech-usage/ [3] https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake... [4] https://github.com/richtr/NoSleep.js [5] https://bugs.webkit.org/show_bug.cgi?id=254545
5 points · Open discussion
According to a 2022 survey [1], the average US adult picks up their phone 352 times per day, or approximately once every 2m43s while they're awake. Inspired by Calm's DoNothingFor2Minutes.com which launched on HN 13 years ago [2], I made this simple webapp to see if my friends and I could go an hour without touching our phones. It is surprisingly difficult. If you're reading HN on your phone, definitely give it a shot. On browsers that support it (iOS 16.4+, most versions of Android Chrome), it uses the Screen Wake Lock API [3] to keep the page open, and falls back to nosleep.js [4] otherwise. From testing on my iPhone 14 Pro Max running iOS 16.6, battery life only went down 3 or 4 percentage points after an hour with the wake lock. Made this as a web app as a quick demo to be compatible across all mobile devices. As an app, we can probab
Read the rest
ly save more on battery + not have the screen on. One caveat is that on iOS this will actually increase your Screen Time (although hopefully reduce your other category usage). I currently only track time on page through Google Analytics 4. No other calls are made to a server, although if we actually wanted to verify that you kept the page open vs. javascript/inspector-system clock-fu, we could add a verified mode that pings the server every X minutes. As a PWA, possibly due to an iOS/Mobile Safari quirk, neither wake lock nor nosleep.js appear to work . [1] https://www.asurion.com/connect/news/tech-usage/ [2] https://news.ycombinator.com/item?id=2124106 [3] https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake... [4] https://github.com/richtr/NoSleep.js
In Show HN: Can you go an hour without touching your phone?

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.