Now you can know the battery status of any devices of people who visit your website, through the Battery Status API. This feature is currently supported on Google Chrome, Opera & Firefox on the desktop and Chrome for Android.

battery status of visitor's device

The Battery API can be implemented with just a few lines of JavaScript code and reveals all the required details about the device’s battery charge level. You’ll get to know:

  • Whether or not the visitor’s battery is currently being charged.
  • How much is the battery charged?
  • If charging, how many seconds until the battery is fully charged.
  • The remaining time in seconds until the battery is completely discharged.

You can even attach event listeners so the battery data is updated as soon as the charge level of the hardware’s battery is changed while the visitor is still on your page.

The code attached in this article will help you to get Battery status of people who visit your website.

This can have several use cases. For instance, when the visitor’s device is running low on battery and not plugged-in, the web developer can choose to automatically save the changes – like the form entries – in local storage before the battery is completely drained.

Here’s a complete list of browsers that currently support the Batter Status API as found on To know more, refer to the documentation on Mozilla and W3.

If you any query regarding this trick then feel free to ask in the comment section. We will be glad to help you.

Enjoy & Stay Techie…