开发者

How Google detects that you are having Slow Connection in Gmail?

开发者 https://www.devze.com 2022-12-23 19:43 出处:网络
do you have any idea about the logic behind the slow c开发者_运维问答onnection in gmail?I don\'t know if this is how Google does it (though it seems sensible), but what I\'d do is perhaps time the ini

do you have any idea about the logic behind the slow c开发者_运维问答onnection in gmail?


I don't know if this is how Google does it (though it seems sensible), but what I'd do is perhaps time the initialisation process - e.g. "have certain key elements been initialised in the document within (say) 30 seconds" - if not, then propose to the user that their connection's slow. The language Google uses, as you know is, "this seems to be taking longer than normal", which suggests to me that they don't have an overly complicated solution to this.


Here is (in vastly simplified form) how I'd imagine they do it.

// Pop an alert after 30 seconds
var timeout = setTimeout(function () {
                             alert('Your connection/computer is slow!');
                         }, 30000);

// Loading logic
loadStuff();

// When done loading (if it took less than 30 seconds), 
// calling this will prevent the alert from popping up.
clearTimeout(timeout);
0

精彩评论

暂无评论...
验证码 换一张
取 消