Detect if mobile chrome's Data saving feature is enable from javascript
Javascript way to detect chrome data saver mode
if('connection' in navigator){ if(navigator.connection.saveData){ console.log(`Your save data mode is = ${navigator.connection.saveData}`) }else{ console.log(`Your save data mode is = ${navigator.connection.saveData}`) }}
For more details follow google developer blog post on Delivering fast and light applications with Save-Data
You can detect if the user has turned on data saving mode in Chrome, Opera or Yandex by looking for a save-data
request header. Dean Hume gives an example of how to detect data saving mode, though unfortunately his example uses a service worker, so it won't work on Opera Mini.
Chrome Data Saver uses a proxy, as do some other Android browsers such as Opera Mini in Extreme mode and UC Browser Mini for Android in Speed Mode.
You should also be able to look for the X-Forwarded-For
header to detect if the Chrome Data Compression Proxy is being used.
I just found a little solution to this. There is something with the ENV variable in PHP. I found out through some random debugging that there is a variable HTTP_SAVE_DATA in the env variable. So my code looks like this:
<?phpif ($_ENV["HTTP_SAVE_DATA"] == "on"){ echo "Datasaver on"; }else{ echo "Datasaver off"; }?>
Hope it works for you :)
(you just have to echo this into an js variable and you can access it via js)