chrisblakley / Nebula

Nebula is a WordPress theme framework that focuses on enhancing development. The core features of Nebula make it a powerful tool for designing, developing, and analyzing WordPress websites consistently, yet its deliberately uncomplicated code syntax also serves as a learning resource for programmers themselves.
https://nebula.gearside.com
GNU General Public License v2.0
141 stars 36 forks source link

Support the prefers-reduced-data media query [🟥 awaiting any support] #2074

Open chrisblakley opened 4 years ago

chrisblakley commented 4 years ago

Browsers are beginning to implement an option that lets users "prefer" less data usage. Nebula can check this in a few places, but the first that comes to mind is predictive loading and font files.

https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-data https://caniuse.com/mdn-css_at-rules_media_prefers-reduced-data

Ex for loading font files:

<link rel="preload" href="fonts/montserrat-regular.woff2" as="font" media="(prefers-reduced-data: no-preference)" crossorigin>

Looks like there is no browser support yet, so it'll be a while before this gets implemented in Nebula.

chrisblakley commented 4 years ago

This is similar to the Save Data header, so I want to do a little more research on this. Does the prefers-reduced-data media query simply pull from the Save Data preference in browser? If so we can just implement the save data check for JavaScript and wait for this media query for things like fonts...

1537

And as a further note, the predictive fetch functionality already checks for the Save Data preference.

//If Save Data is supported and Save Data is requested don't prefetch
if ( nebula.has(navigator, 'connection.saveData') ){ //@todo "Nebula" 0: Replace with optional chaining
    if ( navigator.connection.saveData ){ //@todo "Nebula" 0: Use optional chaining
        return false;
    }
}
chrisblakley commented 1 year ago

As of July 2023 no browser support at all yet.

https://caniuse.com/mdn-css_at-rules_media_prefers-reduced-data

Screen Shot 2023-07-24 at 5 19 38 PM