GoogleChromeLabs / adaptive-loading

Demos for Adaptive Loading - differentially deliver fast, lighter experiences for users on slow networks & devices
Apache License 2.0
264 stars 35 forks source link

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

Open addyosmani opened 5 years ago

addyosmani commented 5 years ago

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:

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 commented 5 years ago

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

anton-karlovskiy commented 5 years ago

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

Glitch Source

Could you please check this demo? It's an attempt to demonstrate https://github.com/GoogleChromeLabs/adaptive-loading/issues/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 commented 5 years ago

@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