riloadr.js
/*
     * Tells whether user's device connection is slow or not.
     * Fast connection assumed if not detected or offline.
     * Based on the Network Api:
     * - MDN: https://developer.mozilla.org/en/DOM/window.navigator.connection
     * - W3C Working draft: http://www.w3.org/TR/netinfo-api/
     * - W3C Editor's draft: http://dvcs.w3.org/hg/dap/raw-file/tip/network-api/Overview.html
     * List of device bandwidths: http://en.wikipedia.org/wiki/List_of_device_bandwidths#Mobile_telephone_interfaces
     */
Tells whether user's device connection is slow or not.
Fast connection assumed if not detected or offline.
Tells whether user ' s device connection is slow or not . Fast connection assumed if not detected or offline .
function hasLowBandwidth() {
        var navigator = win.navigator
          , connection = navigator.connection || navigator.mozConnection ||
                navigator.webkitConnection || navigator.oConnection ||
                navigator.msConnection || {}
          , type = connection.type || 'unknown' 
          , bandwidth = +connection.bandwidth || Infinity; 
        return bandwidth > 0 && bandwidth < 0.1 || /^[23]g|3|4$/.test(type + EMPTYSTRING);
    }
function hasLowBandwidth ( ) { var navigator = win . navigator , connection = navigator . connection || navigator . mozConnection || navigator . webkitConnection || navigator . oConnection || navigator . msConnection || { } , type = connection . type || 'unknown' , bandwidth = + connection . bandwidth || Infinity ; return bandwidth > 0 && bandwidth < 0.1 || / ^[23]g|3|4$ / . test ( type + EMPTYSTRING ) ; }
Tells whether user's device connection is slow or not.
Tells whether user ' s device connection is slow or not .
// polyfill // polyfill // 2G, 3G and KB/s < 100 are considered slow connections. // Offline mode is considered fast connection (bandwidth = 0 or type = none). // According to the W3C, 'bandwidth' is reported in MB/s. // 0.09765625 MB/s = 100 KB/s = 800 kbps. Let's round up to 0.1 MB/s.