save-data icon indicating copy to clipboard operation
save-data copied to clipboard

Implement SaveData JavaScript API

Open da2x opened this issue 7 years ago • 2 comments

Implement the following when dom.netinfo.enabled is flipped to true in Firefox beta

if ('connection' in navigator && navigator.connection.saveData === undefined)
{
  navigator.connection.saveData = true;
  navigator.connection.dispatchEvent(new Event('change'));
}

da2x avatar May 30 '18 03:05 da2x

Work on the Network Information API was discontinued in 2014 and Firefox is unlikely to implement it. Google keeps recommending it to this day, however.

The following content script would partially implement it. However, this may cause more problems than it's worth as the rest of the Network Information API isn't implemented here.

let netinfo = navigator.connection || (navigator.connection = {});
netinfo.saveData = true;
if (netinfo.dispatchEvent)
  netinfo.dispatchEvent(new Event('change'));

da2x avatar Aug 30 '18 02:08 da2x

Technically it should be proibably implemented as:

Object.defineProperty(navigator.connection, "saveData", { get: function() { return true; } });

PRR24 avatar Oct 08 '21 10:10 PRR24