Now, we will get some information regarding download speed: payload size, download time and actual download speed.
<html ng-app="demo-app" ng-controller="demoAppController"> <head> <script type="text/javascript" src="../bins/lib/angular/angular.min.js"></script> <script type="text/javascript" src="../bins/wl-ng-network-speed-tester.js"></script> <script type="text/javascript"> //must set the bins url angular.module('wl-ng-network-speed-tester').value('bins', '../bins'); //create an AngularJS module with a dependency to our bandwidth tester var demoApp = angular.module('demo-app', ['wl-ng-network-speed-tester']); //declare a controller with a dependency on network speed tester service (wlNgNSTService) demoApp.controller('demoAppController', function(wlNgNSTService) { //call the download method of the service wlNgNSTService.download() .then(function(data) { //on success display the download payload size, time and speed alert('Payload: ' + data.size + ' bytes\n' + 'Time: ' + data.time + ' seconds\n' + 'Speed: ' + data.speed + ' bps'); }, function(error) { //on error ... alert('Oops!'); }); }); </script> </head> </html>
The code above is pretty much similar with the one from ping; we call wlNgNSTService.download() method to retrieve raw download speed data measurements.
WiseLoop JavaScript Network Speed Tester is an AngularJS module designed to offer a network bandwidth check against your internet server. Many server types are supported such as Apache HTTP, IIS, Node.js, nginx, Tomcat, Oracle HTTP, jetty and based on the download speed, it can also offer an estimation of internet cost that the user should pay for.