+ 8
Well, you may as well monitor the battery and see how it's going. Mine's just a quick-off; there are better implementations in CodePlayground I think. https://code.sololearn.com/WM633Cfn7I69/?ref=app
4th Dec 2017, 12:16 AM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Try this { navigator.vibrate(9999999); } It drain battery at the rate of 1% per 2 minutes
21st Jul 2019, 7:01 AM
RISHABH MISHRA
RISHABH MISHRA - avatar
+ 1
Just do a lot of useless stuff that targets as many different parts of the phone as possible. Lots of useless multiplication and division to use up the CPU, lots of useless webgl on a canvas to use up the GPU, lots of loading of different images and websites from the internet to use up Wifi. Use the WebAudio API to play sounds. If you don't mind browser popups asking for permission use bluetooth and the camera and the microphone too.
3rd Dec 2017, 9:08 PM
Schindlabua
Schindlabua - avatar
0
"Educational purposes"
4th Dec 2017, 2:23 AM
Zezima
Zezima - avatar
0
@Donald - From what I understand, JavaScript alone isn't something that will drain your battery. Rather, it's when JavaScript initiates the phone to poll a web server for some sort of update. Therefore, you'd likely need to write some JavaScript with an AJAX callback with a high polling frequency of something like every 1 or 2 seconds. A more effective battery drainer could be done in a mobile app with the ability to run the high frequency polling in the background. Therefore, you could be draining the battery while working on another app.
10th Dec 2017, 4:44 AM
David Carroll
David Carroll - avatar
0
Here's my unintentional coding mistake that drained my battery VERY fast: function displayTime() { myTime = new date(); document.getElementById("example").innerHTML = myTime; setInterval(displayTime, 1000); //THIS is the part I messed up (setInterval mutiplies). } This code (my dumbest mistake) COMPLETELY drained my battery!
29th May 2018, 1:01 AM
The Demon Hunter
The Demon Hunter - avatar