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.

Save data for your users

Save data for your users - JavaScript Tutorial

From the course: Vanilla JavaScript: Web Performance Optimization APIs

Start my 1-month free trial

Save data for your users

- [Instructor] Some browsers are adding a Network Information API extension known as the Save Data Flag. When the flag is enabled, currently in Chrome and Opera, it's a Boolean flag telling us if we should be saving data or not. And it sits on top of the Network Information API so it's available on navigator.connection. To read that flag we need to check for navigator.connection.saveData common case. The idea here is that this is a flyer to tell us hey developer be careful with the data that you are consuming from the network because the user or the current conditions are ideal for saving data to improve performance. Today, for example, on Chrome on Android the user can go to Settings enable the Data Saver. If the user uses Data Saver then the flag will be on. And for example future versions of Chrome are making some decisions such as if the user is in 2G. And also has the saveData flag on, then for example it's not going to execute any JavaScript code. It's just plain HTML, because…

Contents