How to detect slow internet connections?

前端 未结 4 1506
终归单人心
终归单人心 2020-12-04 06:52

Currently, most of the popular websites, like google, yahoo detect if the user connection speed is slow and then give a option to load basic version of the website instead o

4条回答
  •  时光说笑
    2020-12-04 07:09

    You could listen to two DOM events, DOMContentLoaded and load, and calculate the difference between the time these two events are dispatched.

    DOMContentLoaded is dispatched when the DOM structure is ready, but external resources, images, CSS, etc. may not be.

    load is dispatched when everything is ready.

    http://ablogaboutcode.com/2011/06/14/how-javascript-loading-works-domcontentloaded-and-onload/

提交回复
热议问题