Skip to content

A web component without GUI to test connection to a web site

License

Notifications You must be signed in to change notification settings

telecomsante/http-ping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<http-ping>

Published on webcomponents.org

Ping http(s) url

A simple no GUI component to ping an url. The component use the fetch API, so use it with recent browser.

By default, the component ping google.com

Nota ; fetch polyfill doesn't work due to CORS problems.

tested on :

  • chrome
  • firefox
  • safary TP ( doesn't work on safari )
  • opera
  • Edge

Quick example

<http-ping interval="2000"></http-ping>
<div class="status"></div>
<div class="delay"></div>
<script>
const ping = document.querySelector('http-ping')
ping.addEventListener('ping-status', evt => {
  document.querySelector('.status').innerHTML = evt.detail.status ? "connected":"not connected";
});
ping.addEventListener('ping-delay', evt => {
  document.querySelector('.delay').innerHTML = evt.detail.delay ? `${evt.detail.delay} ms`:'-';
})
</script>

The component is licensed under the ISC License

Demo and doc are available on https://telecomsante.github.io/http-ping/

About

A web component without GUI to test connection to a web site

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages