Network based image loading using the Network Information API in Service Worker | justmarkup
This is clever—you can use the navigator.connection
API from a service worker (because it’s asynchronous) which means you can have a service worker script that serves differently sized images based on bandwidth.