I see the w3c site in navigator.connection.saveData object but I didn't understand what is the use? and where can I use it on my website?
Please anyone can explain me about this.
According to the Network Information API spec, it looks like saveData
attribute indicates whether the user has requested that data usage be reduced by the user agent:
The
saveData
attribute, when getting, returns true if the user has requested a reduced data usage mode from the user agent, and false otherwise.NOTE
The user may enable such preference, if made available by the user agent, due to high data transfer costs, slow connection speeds, or other reasons.
Regarding your second question,
Where can I use it on my website?
According to MDN (and CanIUse.com), navigator.connection
API is currently only supported in Chrome versions 61+. It will not work with other browsers yet.
In fact, according to CanIUse.com, Chrome only supports the downlink
, effectiveType
& rtt
attributes on navigator.connection
. So you might not be able to use saveData
on Chrome either.
so. navigator.connection.saveData saving data about user connection. Definition of Navigator Connection
The Network Information API provides information about the system's connection in terms of general connection type (e.g., 'wifi', 'cellular', etc.). This can be used to select high definition content or low definition content based on the user's connection. The entire API consists of the addition of the NetworkInformation interface and a single property to the Navigator interface: Navigator.connection.
Example code:
var connection = navigator.connection || navigator.mozConnection || navigator.webkitConnection;
var type = connection.type;
function updateConnectionStatus() {
console.log("Connection type changed from " + type + " to " + connection.type);
}
connection.addEventListener('change', updateConnectionStatus);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With