by jdfreder

jdfreder / pingjs

JavaScript client side ping API.

219 Stars 81 Forks Last release: over 5 years ago (1.0) BSD 3-Clause "New" or "Revised" License 12 Commits 1 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


JavaScript ping API for use in a web browser context. Released under the BSD-3-Clause license, see LICENSE.


There are three possible ways to install this.

HTML script tag

Drag and drop the ping.js file next to an HTML file. Inside the

of the HTML file, use a script tag to load ping.js.  


npm install --save web-pingjs


yarn add web-pingjs


bower install --save web-pingjs


This library uses a UMD header that allows it to be loaded as CommonJS, AMD, or a window global object.

A single function is exported,

. Ping's signature follows:
 * Pings a url.
 * @param  {String} url
 * @param  {Number} multiplier - optional, factor to adjust the ping by.  0.3 works well for HTTP servers.
 * @return {Promise} promise that resolves to a ping (ms, float).


ping('').then(function(delta) {
    console.log('Ping time was ' + String(delta) + ' ms');
}).catch(function(err) {
    console.error('Could not ping remote URL', err);


The user should be aware that this method relies on the HTTP protocol to ping remote URLs. Consequently, ping times are not as reliable as if they were performed using the ICMP protocol.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.