DEV Community


Discussion on: Adaptive Serving using JavaScript and the Network Information API

addyosmani profile image
Addy Osmani Author

In Chrome, we leverage our Network Quality Estimator to plumb through the information that gives you a more accurate effective connection type. Although it isn't possible to entirely replicate this client-side, you could write a polyfill for estimating something like bandwidth speed. JS could download files from a server (with correct caching headers, so not in cache) and approximate download speeds that way. This can be notoriously inaccurate so it's important to consider the tradeoffs.

mrahmadawais profile image
Ahmad Awais ⚡️

That's what I have been thinking. Maybe that could be put in a worker but inaccuracy would be a big tradeoff — I think it's better to keep things civil and let it work for the latest versions. Otherwise, I am thinking we'll have to sideload things for mobiles — also I found out that you can't really estimate the network with smaller files coz many ISPs have dynamic fluctuations in a dynamic IP settings — the initial network push is quite strong to download up to a 1Mb file but real speeds start to reflect as we move closer to 10Mb and that's a terrible idea to be implemented. Maybe, that's me but that's where I am :)