example-singleServer-basic.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="UTF-8" />
  4. <head>
  5. <title>LibreSpeed Example</title>
  6. <link rel="shortcut icon" href="favicon.ico">
  7. </head>
  8. <script type="text/javascript" src="speedtest.js"></script>
  9. <body>
  10. <h1>LibreSpeed Example</h1>
  11. <h4>IP Address</h4>
  12. <p id="ip"></p>
  13. <h4>Download</h4>
  14. <p id="download"></p>
  15. <h4>Upload</h4>
  16. <p id="upload"></p>
  17. <h4>Latency</h4>
  18. <p id="ping"></p>
  19. <script type="text/javascript">
  20. var s=new Speedtest();
  21. s.onupdate = function (data) { // when status is received, put the values in the appropriate fields
  22. document.getElementById('download').textContent = data.dlStatus + ' Mbit/s'
  23. document.getElementById('upload').textContent = data.ulStatus + ' Mbit/s'
  24. document.getElementById('ping').textContent = data.pingStatus + ' ms, ' + data.jitterStatus + ' ms jitter'
  25. document.getElementById('ip').textContent = data.clientIp
  26. }
  27. s.start(); // start the speed test with default settings
  28. </script>
  29. <a href="https://github.com/librespeed/speedtest">Source code</a>
  30. </body>
  31. </html>