All Projects → alfg → Ping.js

alfg / Ping.js

🔔 Ping the web with Javascript.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Ping.js

reachable-url
Given an URL, it resolves as fast as possible, performing a GET without downloading the body.
Stars: ✭ 25 (-90.6%)
Mutual labels:  ping
ddos
Simple dos attack utility
Stars: ✭ 36 (-86.47%)
Mutual labels:  ping
vpnping
Ping nordvpn servers to find the best/fast for you
Stars: ✭ 27 (-89.85%)
Mutual labels:  ping
rustyping
A prettier lightweight colored ping utility written in Rust
Stars: ✭ 23 (-91.35%)
Mutual labels:  ping
PsNetTools
PsNetTools is a cross platform PowerShell module to test network features on Windows, Linux and Mac.
Stars: ✭ 13 (-95.11%)
Mutual labels:  ping
discord-uptime
Discord bot to monitor uptime of services using ping and http requests
Stars: ✭ 46 (-82.71%)
Mutual labels:  ping
pingnoo
An open-source cross-platform traceroute/ping analyser.
Stars: ✭ 149 (-43.98%)
Mutual labels:  ping
ping
Pong revolution.
Stars: ✭ 13 (-95.11%)
Mutual labels:  ping
connection checker
Android library for checking the internet connectivity of a device.
Stars: ✭ 26 (-90.23%)
Mutual labels:  ping
heartbeats
一个基于数据上报的监控系统. 用于监控定时和定期类型服务监控状况
Stars: ✭ 25 (-90.6%)
Mutual labels:  ping
vultr-pingtest
⌚ Test Latency from all Vultr VPS Locations
Stars: ✭ 40 (-84.96%)
Mutual labels:  ping
ioBroker.ping
Pings configured IPs for ioBroker
Stars: ✭ 18 (-93.23%)
Mutual labels:  ping
pexpo
💻 Terminal sending ping tool written in Go.
Stars: ✭ 89 (-66.54%)
Mutual labels:  ping
tcping
⚡️ Just like icmp ping
Stars: ✭ 138 (-48.12%)
Mutual labels:  ping
mcpe-ping
Pings an MCPE server for simple data.
Stars: ✭ 20 (-92.48%)
Mutual labels:  ping
pinger
Pinger is an uptime and status monitoring application.
Stars: ✭ 14 (-94.74%)
Mutual labels:  ping
speedtest-for-digitalocean
Run speed tests for all DigitalOcean datacenters faster than ever.
Stars: ✭ 40 (-84.96%)
Mutual labels:  ping
uptime-bot
A Discord uptime bot which keeps repl.it links up forever!!
Stars: ✭ 14 (-94.74%)
Mutual labels:  ping
lambda-watchtower
Serverless HTTP(S) Endpoint Monitoring With AWS Lambda & CloudWatch
Stars: ✭ 68 (-74.44%)
Mutual labels:  ping
Server-Help
💻 This VSTO Add-In allows the user to ping a list of servers and creates a file for Microsoft Remote Desktop Manager an Excel table. This is used for quickly determining which servers are offline in a list. It is written in 3 different versions as a VSTO Add-In in C# and VB.NET as well as a VBA Add-In.
Stars: ✭ 21 (-92.11%)
Mutual labels:  ping

Ping.js

npm npm

Ping.js is a small and simple Javascript library to ping response times to web servers in Javascript! This is useful for when you want to display realtime ping times on a status page which are relative to the user.

See Notes below for how this works.

JS Fiddle Example: http://jsfiddle.net/alfg/sr0tpn4x/

Example in jQuery: http://jsfiddle.net/alfg/xjqbvt2o/

Usage

  • Download the distribution files in dist to your project.
var p = new Ping();

p.ping("https://github.com", function(err, data) {
  // Also display error if err is returned.
  if (err) {
    console.log("error loading resource")
    data = data + " " + err;
  }
  document.getElementById("ping-github").innerHTML = data;
});

or import as a module:

$ npm install ping.js
import Ping from 'ping.js';

or use the jsdelivr CDN:

<script src="https://cdn.jsdelivr.net/gh/alfg/[email protected]/dist/ping.min.js" type="text/javascript"></script>

See demo/react-example for an example in React.

API

var p = new Ping(opt);

Ping([options])

Create Ping instance.

options

Type: Object

favicon Override the default favicon.ico image location.

timeout Optional - Set a timeout in milliseconds.

p.ping(source, callback)

Creates a ping request to the source.

source IP address or website URL, including protocol and port (optional). Example: https://example.com:8080

callback(err, ping) Callback function which returns an error and the response time in milliseconds.

Development

Install project:

git clone https://github.com/alfg/ping.js.git
cd ping.js
npm install
npm install -g grunt-cli

Run grunt to build distribution files:

grunt

Open demo/index.html in a browser to test results.

Notes

Javascript itself doesn't have a native way of sending a "ping", so results may not be completely accurate. Since xhr 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.

License

MIT License © Alfred Gutierrez

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].