X
Tech

Chrome JavaScript timer throttling: Google's tests show it saves up to 2 hours' battery life

Chrome will soon throttle JavaScript timers in the background, so the browser uses significantly less power.
Written by Liam Tung, Contributing Writer

Google looks set for Chrome 86 to slash how much battery life the browser consumes. It's already experimenting with blocking unruly ads that drain battery life and jam up networks and now it is targeting power-hungry JavaScript timers.    

To test the JavaScript timing throttling feature, users can download the current Chrome from the Canary developer channel and type into the address bar 'chrome://flags' and then either search 'JavaScript' or type in 'chrome://flags/#intensive-wake-up-throttling'. This experiment setting will throttle JavaScript timers in the background. 

"When enabled, wake-ups from DOM Timers are limited to one per minute in a page that has been hidden for five minutes," Google's Chromium developers note. 

SEE: Virtual hiring tips for job seekers and recruiters (free PDF) (TechRepublic)    

The Chromium team have also published the results of experiments it ran in a document titled 'Throttling JavaScript Timers to Reduce Battery Usage in Background Tabs', which explains that website developers are using these timers for analytics in a way that doesn't benefit the user and drains the battery on macOS, Windows, and Linux devices. 

"We used Devtools to inspect the work done by popular sites in the background. We found that a lot of work was done from JavaScript timers. Furthermore, we found that the work done from these JavaScript timers was often not valuable to the user when the page was backgrounded (eg checking if scroll position changed, reporting logs, analyzing interactions with ads)."

So the group guessed that reducing the number of wake-ups from JavaScript timers on a backgrounded page could extend battery life with no impact on the user, such as causing a page to freeze. 

They noted that wake-ups in background pages are currently limited to one wake-up per second and about 1% of CPU use. Google's experiments test limiting these wake-ups to one per minute. 

The Chromium team ran one experiment on Chrome with 36 background tabs and the about:blank tab in the foreground, and a second experiment with 36 background tabs and YouTube in the foreground playing a video in fullscreen. The background tabs included popular sites like Twitter, logged in Gmail, Amazon, and Best Buy.   

Using a highly-specced MacBook Pro 15-Inch 2018, the group then tested how long it took to drain its battery on Chrome with no throttling, Chrome with throttling, and Safari 13.1. 

SEE: What is a Chief Technology Officer? Everything you need to know about the CTO

Even with throttling turned on in Chrome, the MacBook battery was drained faster than Safari in that configuration. However, the throttling puts Chrome much closer to Safari's impact on battery life than previously. 

"At the median, throttling JavaScript timers aggressively extends the battery life by almost two hours (28%) for a user with many background tabs, when the foreground tab is about:blank," the Chromium team writes.  

In the YouTube tests, throttling JavaScript timers aggressively extended the battery life by almost 36 minutes or about 13%. Safari was not tested in this scenario.

chrome-js-timer-throttling.png

Google tested how long it took to drain its battery on Chrome with no throttling, Chrome with throttling, and Safari 13.1. 

Image: Google
Editorial standards