In 2007, we were invited to speak at the Apple WWDC event. At the time we didn’t know why we were invited. We later learned that because there was initially no native SDK, developers were advised to use JavaScript, HTML, and CSS to create iPhone apps, and were encouraged to attend our session. Obviously the world has changed quite a bit since 2007, but one of the questions we asked the Apple team at the time was: “What APIs would be available to developers to work with phones?” The answer we received was that Apple intended to work with the standard bodies before adding new web APIs. One of the first APIs we wanted to see was information about the network speed, simply because mobile networks are considerably slower than ethernet and wifi connections.

Network Information API

Fast forward 12 years, and after many attempts over the years by developers to test network speeds, there is a new Network Information API by the WICG: “The Network Information API enables web applications to access information about the network connection in use by the device.” The proposal introduces a few simple APIs:

  • navigator.connection.type – the type of connection, which can be bluetooth, cellular, ethernet, mixed, none, other, unknown, wifi, or wimax
  • navigator.connection.effectiveConnectionType – a measure of how fast the connection is, which can be 2g, 3g, 4g, or slow-2g
  • downlinkMax – upper bound on the downlink speed of the first network hop in megabits per second
  • downlink – the effective bandwidth estimate in megabits per second, based on recently observed application layer throughput
  • rtt – effective round-trip time estimate in milliseconds based on recently observed application-layer RTT measurements
  • saveData – true if the user requests a reduced data usage mode

Browser Support and Use Cases

Full support for the Network Information API exists in Chrome for Android (78+), Firefox for Android (68+), and Samsung Internet (10.1+). Partial desktop browser support exists on Chrome 79+ and Edge 76+. There are many possible use cases for the Network Information API. For example, bandwidth consumption could get reduced over slow or cellular networks, assets could get cached differently via service workers, and an offline connection might get assumed if the connection speed is so slow that it’s effectively the same as being offline.

Conclusion

While it has taken more than a decade since the first iPhone was released to get this API, this is an exciting proposal to watch as it will hopefully allow applications to deliver streamlined options for slower internet connections, and allow users to request smaller data requests when their bandwidth is limited or metered. If you need help creating highly performant applications or leveraging emerging APIs and best practices, please contact us to discuss how we can help!