Mattepuffo's logo
Eseguire un PING in Javascript con ping.js

Eseguire un PING in Javascript con ping.js

ping.js è una piccola libreria che ci permette di eseguire una sorta di PING in Javascript.

Da prendere con le molle ovviamente; guardate la descrizione direttamente dal canale di GitHub:

Javscript itself doesn't have a native way of sending a "ping", so results may not be completely accurate. Since ajax requests are affected by cross-domain issues (CORS), they are blocked by default. ping.js is using a method of loading a favicon.ico image from any host and timing the response time. If the favicon image doesn't exist, an error is returned along with the ping value. If there's a better way to do this in Javascript, feel free to create an issue, or pull request so I can review.