Comments (9)
Excellent. That is the behaviour I would expect. This feature should only ever work (be true) if Lite Mode is enabled.
from adaptive-loading.
@addyosmani
Working on this project, I found something interesting in using Save-Data client hint.
<meta http-equiv="Accept-CH" content="DPR, Width, Viewport-Width, ECT, Device-Memory, Save-Data">
<meta http-equiv="Accept-CH-Lifetime" content="86400">
With above code snippet in the website, Save-Data
is not attached to request headers.
I was testing on Google Chrome browser and even though I attached Save-Data
client hint to request as header, I couldn't capture Save-Data request header.
const myHeaders = new Headers({
'Save-Data': 'on',
'Data-Saver': 'on'
});
fetch('/network-memory-considerate-model', {
headers: myHeaders
})
.then(response => response.json())
.then(result => {
setExperienceType(result.experienceType);
});
I found this note in the doc.
So I think it's disabled on Google Chrome browser for computers. Please check the video capture in the slack channel.
video capture on Google Chrome
As you can see in above code snippet and screenshot, I set 2 custom request headers Save-Data
and Data-Saver
, Save-Data
is not available while Data-Saver
(any name other than Save-Data
) is always available.
I also tested this scenario on Firefox and Microsoft Edge and on both browsers Save-Data
is always available, let alone Data-Saver
.
Microsoft Edge:
Firefox:
I'm not sure how Twitter was able to use Save-Data
request header even on Google Chrome browser.
Twitter:
I thought that the fetch API
might have the problem so tried axios and request but not able to use Save-Data
request header on Google Chrome browser.
So I'm going to use Data-Saver
request header for now to implement this project.
from adaptive-loading.
So I'm going to use Data-Saver request header for now to implement this project.
I'll take blame for not catching that it was going to be difficult to debug Save Data on desktop now that the Chrome extension for Data Saver has been deprecated (leaving Data Saver/Lite Mode for Android as the main way to use the feature and test it).
Do you have access to a BrowserStack account? It's possible to test and debug Data Saver from a real Android device. You need to go to Settings > Lite Mode and enable it. Here's a test using https://client-hints-demo.appspot.com/http-equiv.html (Accept-CH and Accept-CH-Lifetime meta http-equiv response headers) where you can see Save Data coming through as expected:
from adaptive-loading.
@addyosmani
I tested using BrowserStack Samsung Galaxy 10.
With the Lite Mode setting enabled, we can capture save-data
request header on server side.
But with the Lite Mode setting disabled, we can't capture save-data
request header on server side, even though we manually attached Save-Data
header to the request.
from adaptive-loading.
Glitch Source
Please check the above Glitch application.
Actually both of Save-Data Client Hint based demo on server side as well as React hook based demo on client side are developed but on Glitch it's a bit difficult to run Node.js serving create-react-app project. So please try client side demo first.
I'll get it up and running on our Adaptive Loading firebase instance when landing on the PR.
A bit of refinement is left yet.
from adaptive-loading.
@addyosmani
Glitch app is updated for load image feature which can be found in the center of image on lite mode.
from adaptive-loading.
from adaptive-loading.
@addyosmani
For now, on Glitch, it's a bit difficult to get it working with Lite Mode turned on in Chrome for Android because Node.js is not running.
But the implementation is done and working in local development environment. We can deploy it to Adaptive Loading firebase instance with functions.
Then we can test it online.
from adaptive-loading.
@addyosmani
I think Twitter applies adaptive loading to videos as well as images like autoplay
.
We could also apply autoplay
feature as we have the interface here.
from adaptive-loading.
Related Issues (20)
- Client Hints + initial state Adaptive Loading Hooks HOT 11
- Alternative ways of obtaining device information (other than UA string)? HOT 4
- [Demo] Network-aware code loading (eBay) HOT 11
- Media Capabilities API
- [WIP] Microsite HOT 17
- [Hooks] Save Data hook HOT 11
- [Naming] review demo projects names HOT 3
- [Demo] Dixie mechanical keyboard HOT 3
- [hooks] Memory hook feedback HOT 2
- [hooks] Return values feedback HOT 11
- [Demo] Lottie Web HOT 3
- [Demo] Enhance Twitter Data Saver demo HOT 8
- [Demos] Polish HOT 7
- [Demos] YouTube HOT 19
- [Config] Implement API key safety restrictions HOT 1
- [Update] Updating the adaptive-loading demos to use the new package of hooks HOT 2
- [Microsite] React Hooks page
- [Microsite] Demos page
- [Microsite] Resources page HOT 3
- [Microsite] Deployment HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from adaptive-loading.