top | item 6140396

JavaScript ‘wake’ event

39 points| shawndumas | 12 years ago |blog.alexmaccaw.com | reply

7 comments

order
[+] exDM69|12 years ago|reply
If you do a timeout polling like this, it might be a good idea to bump up the timout to several minutes (not every 20 seconds like in the example code).

Peridically waking up an idle CPU just to check the time has a surprisingly big effect on power consumption. This might be a real issue if you have this page open in your smartphone browser but the phone is idle but not sleeping in your pocket.

[+] jcampbell1|12 years ago|reply
I was under the impression that power mode switching took ~50 micro seconds, which means power savings modes toggle on an off between keystrokes.

The problem here isn't awaking the CPU, but rather awaking the radios. If you don't turn on the radios, polling every 20 seconds shouldn't be a problem. I'd mix this approach with something like the Page Visibility API, so you don't fetch data unless the site is the active tab.

[+] lucb1e|12 years ago|reply
Been there done that. Never thought it was worth making a plugin for or even blogging about it though.
[+] caludio|12 years ago|reply
... and that post to be in HN front page. Wow.