From the course: Vanilla JavaScript: Web Performance Optimization APIs

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Read network information

Read network information - JavaScript Tutorial

From the course: Vanilla JavaScript: Web Performance Optimization APIs

Start my 1-month free trial

Read network information

- [Instructor] Now that we know how to track and get all the available performance timeline information, it's time to see some APIs that will help us into making decisions about the current situation to improve user experience. Let's start talking about the Network Information API. It's available on some browsers only. Unfortunately, there are different versions of the specs out there. Let's say, a 90% of the browsers supporting this API are currently using the latest spec, but we might have users with older spec, so we need to create some conditionals there. It's available in the navigator object, that means it's on Windows, so in the normal context, and also in web workers context. It's using decimal units to get the information about the current bandwidth, for example. Decimal units means that 1 Kilobyte it's 1000 bytes. To use the API, we just need to access navigator.connection and we can se there are several properties that we can read, such as type, downlink or saveData. Let's…

Contents