I found that the ajax response times were very different using different browsers. The server (mongoose) was running locally so network issues are excluded.
These are my findings:
- Firefox 11-23ms
- Chrome 6-130ms
- Safari (webkit) 1004-1020ms
- Maxthom (webkit) alternates between 30 and 1030ms
- Arora (qt/webkit) 1017-1025ms
- embeddedchromium alternates between 15 and 315ms
And here is the code for everyone to check:
<html>
<head>
<title>Embedded Response Slow demo</title>
</head>
<body>
<script>
var time = 0;
function mouseClicked()
{
time = new Date().getTime();
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
time = new Date().getTime() - time;
document.getElementById('link').innerHTML
= "Response took "+time+"ms.";
}
}
xmlhttp.open("GET","responsetest.html?q="+time,true);
xmlhttp.send();
}
</script>
<div><a onclick="mouseClicked()" id="link" href="#" >click me</a></div>
</body>
</html>
For a responsive GUI, I really need to work this out. Does anybody have an Idea how I can get short response times consistently?
(I reworked the whole question to be simpler and contain code. Now I removed jQuery completely from the equation and added Safari results.)