JSFiddle - React, Tailwind, and code Playground
JavaScript
function waitForIt(){
var start=new Date();
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "WaitForIt", false);
xhttp.send();
var end=new Date();
}
function wait(time){
var start=new Date();
var end=new Date();
while((end-start<time)){
waitForIt();
end=new Date();
}
return (end - start);
}
function sleeps(){
var start=new Date();
var ifram = document.createElement('iframe');
ifram.src='';
document.appendChild(ifram);
var end=new Date();
return (end - start);
}
document.getElementById("demo").innerHTML=sleeps();