Press "Enter" to skip to content

How to Use Online Ping | Vanilla JavaScript Ping.js

Ping.js is a small and simple javascript library for ping response times for servers in pure javascript. Ping.js is a vanilla JavaScript library to supply a web-based ping performance on the client-side. This is useful when you want to view real-time ping times on the User Status page.

How to make use of it:

1. Install & download the bundle.

# NPM
$ npm i ping.js --save

2. Import the Ping.js as an ES module.

import Ping from 'ping.js';

3. Load the compiled JavaScript from the dist folder.

4. Create a brand new Ping instance.

var p = new Ping();

5. Ping a selected web site 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 choices to customize the Ping software.

var p = new Ping({

    // replace it with your own favicon
    favicon: "/favicon.ico",

    // timeout in ms
    timeout: 0,

    // whether to log errors
    logError: false

});

See Demo And Download

Official Website(alfg): Click Here

This superior jQuery/javascript plugin is developed by alfg. For extra Advanced Usages, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.