
Ping.js is a vanilla JavaScript library to provide an online ping functionality on the client-side.
How to use it:
1. Install & download the package.
# NPM $ npm i ping.js --save
2. Import the Ping.js as an ES module.
import Ping from 'ping.js';
3. Or load the compiled JavaScript from the dist folder.
<script src="dist/ping.min.js"></script>
4. Create a new Ping instance.
var p = new Ping();
5. Ping a specific website and get the response time.
p.ping("https://cssscript.com", function(err, data) {
if (err) {
console.log("no response")
}
document.getElementById("output").innerHTML = data;
});6. Available options to customize the Ping tool.
var p = new Ping({
// replace it with your own favicon
favicon: "/favicon.ico",
// timeout in ms
timeout: 0,
// whether to log errors
logError: false
});Changelog:
v0.3.0 (04/14/2021)
- Support ES6 Promise






