DEV Community

talent
talent

Posted on

13 3

Checking for internet speed using Javascript

Check Internet speed using JavaScript to render elements conditionally

The downlink read-only property of the Network
Image descriptionInformation interface returns the effective bandwidth estimate in megabits per second, rounded to the nearest multiple of 25 kilobits per seconds. This value is based on recently observed application layer throughput across recently active connections, excluding connections made to a private address space.

if (navigator.connection.downlink < 5){
   //logic for bad internet speeds
} else {
      //logic for good internet speeds

}

Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
dennistobar profile image
Dennis Tobar

mmmm... around 65% of usage: caniuse.com/mdn-api_navigator_conn... and in Firefox you need authorize the feature
Good idea, but it need to be checked before to use :)

(see developer.mozilla.org/en-US/docs/W... )

Collapse
 
sojinsamuel profile image
Sojin Samuel

Bravo

Collapse
 
talenttinaapi profile image
talent

The things Javascript can do are pretty amazing!!

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay