Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat) Client Hints prototype for adaptive code serving #39

Open
addyosmani opened this issue Sep 9, 2019 · 3 comments
Open

(feat) Client Hints prototype for adaptive code serving #39

addyosmani opened this issue Sep 9, 2019 · 3 comments

Comments

@addyosmani
Copy link
Collaborator

This is a follow-up to #38, which explores using Client Hints for adaptive code loading. Rather than just using CH for deciding whether low or high quality resources should be sent down to the client, we will use them to decide what JavaScript bundles should be served.

The idea we want to enable is the following:

  • A user arrives on the site and is served an experience
  • If they are on 2G/3G (ECT), a lightweight experience is served
  • If they have low-memory, a lightweight experience is served
  • All other users are given the "full" experience

What will differ between this example and others is that we really want to stress the difference possible between a lightweight version vs. heavy. A heavy version could include more than one component pulling in a number of different JavaScript dependencies.

Let's brainstorm what the best demo for this should be.

@addyosmani
Copy link
Collaborator Author

Some ideas (that could form part of an app):

@anton-karlovskiy
Copy link
Contributor

@addyosmani
https://server-adaptive-loading-js.firebaseapp.com/

Glitch Source

GitHub

Could you please check this demo?
It's an attempt to demonstrate #39
JS bundle adaptive loading based on Client Hints.
Here react-magnifier package is a JS chunk and it's loaded when ECT is 4g and memory is greater than 4GB.
So we can switch the light and heavy experience just by throttling the network quality in Chrome DEV tools.
Firebase app is build version and Glitch app is dev version.
Thanks to create-react-app webpack configuration, I think we can split the package as a chunk and conditionally load the JS chunk based on Client Hints.

@anton-karlovskiy
Copy link
Contributor

@addyosmani a developer might wonder why the heavy chunk is so small
It's because the heavy component is distributed into heavy component chunk and react-magnifier chunk.
So we can think of both heavy component and react-magnifier as a real heavy chunk.
That's why heavy chunk is smaller than light chunk.
heavy
light

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants