The best way to check your internet speed is to use our online speed test tool. Most internet service providers have their own speed test tools available on their websites. However, our inhouse developed tool helps to measure your download and upload speeds with utmost accuracy.
// This code will measure the speed of a web page’s loading time. // Step 1: Create a start time variable let startTime = Date.now(); // Step 2: Set up an event listener to listen for the “load” event on the page window.addEventListener(“load”, function(){ // Step 3: Create an end time variable let endTime = Date.now(); // Step 4: Calculate the difference between the start and end times let totalTime = endTime – startTime; // Step 5: Output the total loading time to the console console.log(“The page loaded in ” + totalTime + ” milliseconds.”); });
// Create a variable to store the speed of the internet connection // Create a function to test the speed of the internet connection // Call the speedTest() function // Log the speed of the internet connection
var internetSpeed;
function speedTest() {
// Use the Date.now() method to measure the time before and after the download
var startTime = Date.now();
// Create a new HTTP request
var request = new XMLHttpRequest();
// Assign the request to a URL
request.open(‘GET’, ‘https://www.forbixindia.com/electronics/sitemap.txt‘, true);
request.send();
// Once the request is complete, measure the time again
request.onload = function() {
var endTime = Date.now();
// Calculate the difference between the two times
var timeDifference = endTime – startTime;
// Calculate the speed by dividing the size of the file by the time difference
internetSpeed = request.responseText.length / timeDifference;
};
}
speedTest();
console.log(‘Internet speed: ‘ + internetSpeed
Videos
The post Internet speed test online first appeared on FORBIX SEMICON®.
This post first appeared on Wireless Nurse Call Systems ⋆ FORBIX SEMICON, please read the originial post: here