Giter Club home page Giter Club logo

Comments (9)

addyosmani avatar addyosmani commented on June 1, 2024 1

Excellent. That is the behaviour I would expect. This feature should only ever work (be true) if Lite Mode is enabled.

from adaptive-loading.

anton-karlovskiy avatar anton-karlovskiy commented on June 1, 2024

@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);
});

no save-data   data-saver in chrome

I found this note in the doc.
save-data-workflow-in-chrome
data-saver-feature
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:
save-data   data-saver in edge
Firefox:
save-data   data-saver in firefox

I'm not sure how Twitter was able to use Save-Data request header even on Google Chrome browser.
Twitter:
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.

addyosmani avatar addyosmani commented on June 1, 2024

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:

image

from adaptive-loading.

anton-karlovskiy avatar anton-karlovskiy commented on June 1, 2024

@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.

anton-karlovskiy avatar anton-karlovskiy commented on June 1, 2024

@addyosmani

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.

anton-karlovskiy avatar anton-karlovskiy commented on June 1, 2024

@addyosmani
Glitch app is updated for load image feature which can be found in the center of image on lite mode.

from adaptive-loading.

addyosmani avatar addyosmani commented on June 1, 2024

from adaptive-loading.

anton-karlovskiy avatar anton-karlovskiy commented on June 1, 2024

@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.

anton-karlovskiy avatar anton-karlovskiy commented on June 1, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.