DevCheater.com - javascript sleep

Have you ever needed the sleep command in JavaScript? Usually you can use the existing setTimeout(), clearTimeout() and setInterval() to accomplish what you want and in those cases you should use the native functions. But if you really need the sleep or wait statement lets go through the options and see what code might work the best.

Of course you can always skip to the conclusion.

What should the requirements of the sleep method be? I think power basic described it the most clearly as:
Pause the current thread of the application for a specified number of milliseconds (mSec), allowing other processes (or threads) to continue.
Power Basic sleep() - Win32 Sleep() - Java Thread.sleep()

The different ways in which we will make a javascript sleep function are:

JavaScript sleep by loop

The most basic way would be something like this:

<script type="text/javascript">
// bad implementation
function sleep(milliSeconds){
	var startTime = new Date().getTime(); // get the current time
	while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}
</script>

We are using a while loop on line 3 that continually evaluates the current time against the time when we should stop blocking. This loop will run as fast as the browser will let it all the while using up valuable cpu resources. Checking the time might not seem like much but doing it thousands (or tens of thousands) of times per second make a noticeable performance impact on your computer (try it and watch your cpu meter). This code will "pause" your thread but will also use all the resources your computer will give it. javascript sleep by loop example

Analysis for javascript sleep loop

This implementation does block the running javascript but it also consumes all the CPU resources it can while sleeping and freezes all other javascript in the page (in all browsers tested).

JavaScript sleep by Java Applet

One solution to the problem has ended up being in a Java Applet. Since you can communicate between javascript and java applets and that communication is blocking we can use Java's Thread.sleep() method (which when run uses almost no resources).


<applet code="DevCheater.class" name="devCheater" id="devCheater" mayscript="true" height="1" width="1"></applet>

<script type="text/javascript">

	function sleep(milliSeconds){
		// runs Java Applets sleep method
		document.devCheater.sleep(milliSeconds); 
	}

</script>

This version might look simpler then the last one but that is because some of the code is hidden away in the DevCheater.class Java file. On line 1 you can see an applet tag that utilizes my DevCheater.class Java class, this is what loads the Java program into the page so that it can be accessed by any javascript on it. Now this is where the bad news comes in. Not all browsers will allow other javascript to run while waiting for the Java sleep method to finish. Essentially sleeping all javascript on the page... See for your self JavaScript sleep by java applet example

Analysis for Java Applet

We do block the running javascript and no extra CPU resources are used while sleeping. This method does not freeze all other javascript in the page (except when using Chrome). Unfortunately it does require a java plug-in to be installed for their browser which limits its usefulness.

JavaScript sleep by Flash

If we try using Java then why not adobe flash too. In this attempt I created a flash application that has a method called very unoriginally "flashSleep()". I now use javascript to call my flash method and pass in the number of milliseconds to sleep. But unfortunately this method also results in a freeze for most browsers I tested.

<script type="text/javascript">

	function sleep(milliSeconds){
		// call sleep method in flash
		getFlashMovie("flashSleep").flashSleep(milliSeconds);
	}

	function getFlashMovie(movieName){
		// source: http://kb2.adobe.com/cps/156/tn_15683.html
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		return (isIE) ? window[movieName] : document[movieName];
	}

</script>
	<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="50" height="50" id="flashSleep" align="middle">
	<param name="allowScriptAccess" value="sameDomain" />
	<param name="allowFullScreen" value="false" />
	<param name="movie" value="flashSleep.swf" />
	<param name="quality" value="high" />
	<param name="bgcolor" value="#ffffff" />	
	<embed src="flashSleep.swf" quality="high" bgcolor="#ffffff" width="50" height="50" name="flashSleep" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
	</object>

Analysis for Flash

Using adobe flash is no better then the rest when it comes to freezing. For that reason this method should not be used. javascript sleep by flash example

JavaScript sleep by XMLHttp

Another way is to use server communication with XMLHttp.

<script type="text/javascript">

function sleep(milliSeconds){
	var resource;
	var response;
	if(typeof ActiveXObject == 'undefined'){
		resource = new XMLHttpRequest();
	}
	else{
		// IE
		resource = new ActiveXObject("Microsoft.XMLHTTP");
	}

	try{
		resource.open('GET', 'sleep.php?milliSeconds=' + milliSeconds, false);
		resource.send(null);
		response = resource.responseText; // JavaScript waits for response
	}
	catch(e){
		alert(e);
	}
	
	return true;
}
	
</script>
<?PHP
	$milliSeconds = intval($_REQUEST['milliSeconds']);
	if($milliSeconds > 60*1000){
		// limit server abuse
		$milliSeconds = 10;
	}
	
	usleep($milliSeconds * 1000); // note: usleep is in micro seconds not milli
	echo "done";
?>
Here we try to load another file from the server called sleep.php and send the the number of milli seconds we want the sleep to be. The PHP script then uses that value in its native usleep function. But again some browsers will freeze all javascript when this is run. javascript sleep by XMLHttp example

Note: Any type of server software could be used in the place of Apache and PHP. IIS and ASP for example.

Analysis for XMLHttp

This does block the running javascript and no extra CPU resources are used on the user’s computer but it does add extra load on your server. As well this implementation does freeze all other javascript on the page in all browsers tested. The added server connections makes this method unacceptable for any use because it is bound to max out the servers allowed connections, essentially creating your own DDoS attacks on your server :-(

Conclusion

As you can see from the results listed below in almost every case trying to implement a sleep function in javascript has the unwanted side effect of freezing the entire browser. And for that reason no implementation should be used. Instead the native setTimeout() or setInterval() functions should always be choosen.

Browser Operating System Implementation Freeze
Chrome 2.0.172.43 Windows 5.1 loop 1 Yes
Chrome 2.0.172.43 Windows 5.1 XMLhttp 1 Yes
Chrome 2.0.172.43 Windows 6.0 java 1 Yes
Chrome 2.0.172.43 Windows 6.0 loop 1 Yes
Chrome 2.0.172.43 Windows 6.0 XMLhttp 1 Yes
Chrome 3.0.195.21 Windows 5.1 XMLhttp 1 Yes
Chrome 3.0.195.21 Windows 6.0 java 1 Yes
Chrome 3.0.195.21 Windows 6.0 loop 1 Yes
Chrome 3.0.195.21 Windows 6.0 XMLhttp 1 Yes
Chrome 3.0.195.21 Windows 6.1 java 1 Yes
Chrome 3.0.195.21 Windows 6.1 loop 1 Yes
Chrome 3.0.195.25 Windows 5.1 XMLhttp 1 Yes
Chrome 3.0.195.25 Windows 6.0 java 1 Yes
Chrome 3.0.195.25 Windows 6.0 loop 1 Yes
Chrome 3.0.195.25 Windows 6.0 XMLhttp 1 Yes
Chrome 3.0.195.27 Windows 5.1 java 1 Yes
Chrome 3.0.195.27 Windows 5.1 loop 1 Yes
Chrome 3.0.195.27 Windows 5.2 loop 1 Yes
Chrome 3.0.195.27 Windows 6.0 java 1 Yes
Chrome 3.0.195.27 Windows 6.0 XMLhttp 1 Yes
Chrome 3.0.195.27 Windows 6.1 flash 1 No
Chrome 3.0.195.27 Windows 6.1 XMLhttp 1 Yes
Chrome 3.0.195.33 Windows 5.1 java 1 Yes
Chrome 3.0.195.33 Windows 5.1 loop 1 Yes
Chrome 3.0.195.33 Windows 5.1 XMLhttp 1 Yes
Chrome 3.0.195.33 Windows 6.0 loop 1 Yes
Chrome 3.0.195.33 Windows 6.1 flash 1 Yes
Chrome 3.0.195.33 Windows 6.1 java 1 Yes
Chrome 3.0.195.33 Windows 6.1 loop 1 Yes
Chrome 3.0.195.33 Windows 6.1 XMLhttp 1 Yes
Chrome 3.0.195.38 Windows 5.1 loop 1 Yes
Chrome 3.0.195.38 Windows 6.1 XMLhttp 1 Yes
Chrome 4.0.201.1 Windows 5.1 loop 1 Yes
Chrome 4.0.201.1 Windows 6.0 flash 1 No
Chrome 4.0.201.1 Windows 6.0 java 1 No
Chrome 4.0.201.1 Windows 6.0 java 1 Yes
Chrome 4.0.201.1 Windows 6.0 loop 1 Yes
Chrome 4.0.201.1 Windows 6.0 XMLhttp 1 Yes
Chrome 4.0.203.2 Windows 5.1 java 1 Yes
Chrome 4.0.206.1 Windows 5.1 loop 1 Yes
Chrome 4.0.223.11 Linux i686 XMLhttp 1 Yes
Chrome 4.0.223.16 Windows 5.1 loop 1 Yes
Chrome 4.0.249.0 Windows 5.1 flash 1 Yes
Chrome 4.0.249.0 Windows 5.1 java 1 Yes
Chrome 4.0.249.0 Windows 5.1 XMLhttp 1 Yes
Chrome 4.0.249.22 Other java 1 Yes
Chrome 4.0.249.22 Windows 5.1 flash 1 Yes
Chrome 4.0.249.22 Windows 5.1 XMLhttp 1 Yes
Chrome 4.0.249.43 Linux i686 loop 1 Yes
Chrome 4.0.249.43 Other loop 1 Yes
Chrome 4.0.249.64 Windows 6.1 loop 1 Yes
Chrome 4.0.249.78 Windows 5.1 loop 1 Yes
Chrome 4.0.249.78 Windows 6.1 java 1 Yes
Chrome 4.0.249.89 Windows 5.1 java 1 Yes
Chrome 4.0.249.89 Windows 5.1 loop 1 Yes
Chrome 4.0.249.89 Windows 5.1 XMLhttp 1 Yes
Chrome 4.0.249.89 Windows 6.0 flash 1 Yes
Chrome 4.0.249.89 Windows 6.0 java 1 Yes
Chrome 4.0.249.89 Windows 6.0 XMLhttp 1 Yes
Chrome 4.0.249.89 Windows 6.1 flash 1 Yes
Chrome 4.0.249.89 Windows 6.1 java 1 Yes
Chrome 4.0.249.89 Windows 6.1 loop 1 Yes
Chrome 4.0.249.89 Windows 6.1 XMLhttp 1 Yes
Chrome 4.0.267.0 Linux i686 flash 1 Yes
Chrome 4.0.288.1 Other flash 1 Yes
Chrome 4.0.288.1 Other loop 1 Yes
Chrome 4.0.288.1 Other XMLhttp 1 Yes
Chrome 4.0.288.1 Windows 5.1 java 1 Yes
Chrome 4.0.288.1 Windows 6.1 flash 1 Yes
Chrome 4.0.302.3 Windows 6.1 flash 1 Yes
Chrome 4.0.302.3 Windows 6.1 loop 1 Yes
Chrome 4.0.302.3 Windows 6.1 XMLhttp 1 Yes
Chrome 4.1.249.1036 Windows 5.1 flash 1 Yes
Chrome 4.1.249.1036 Windows 5.1 java 1 Yes
Chrome 4.1.249.1036 Windows 5.1 loop 1 Yes
Chrome 4.1.249.1036 Windows 5.1 XMLhttp 1 Yes
Chrome 4.1.249.1042 Windows 6.1 loop 1 Yes
Chrome 4.1.249.1042 Windows 6.1 XMLhttp 1 Yes
Chrome 4.1.249.1045 Windows 5.1 loop 1 Yes
Chrome 4.1.249.1045 Windows 6.1 loop 1 Yes
Chrome 4.1.249.1064 Windows 5.1 flash 1 Yes
Chrome 4.1.249.1064 Windows 5.1 java 1 Yes
Chrome 4.1.249.1064 Windows 5.1 loop 1 Yes
Chrome 4.1.249.1064 Windows 5.1 XMLhttp 1 Yes
Chrome 4.1.249.1064 Windows 5.2 loop 1 Yes
Chrome 4.1.249.1064 Windows 6.0 java 1 Yes
Chrome 4.1.249.1064 Windows 6.0 loop 1 Yes
Chrome 4.1.249.1064 Windows 6.1 java 1 Yes
Chrome 4.1.249.1064 Windows 6.1 loop 1 Yes
Chrome 4.1.249.1064 Windows 6.1 XMLhttp 1 Yes
Chrome 5.0.308.0 Other loop 1 Yes
Chrome 5.0.311.0 Linux i686 loop 1 Yes
Chrome 5.0.311.0 Linux i686 XMLhttp 1 Yes
Chrome 5.0.322.2 Macintosh 10_5_8 loop 1 Yes
Chrome 5.0.337.0 Linux i686 loop 1 Yes
Chrome 5.0.342.9 Linux i686 loop 1 Yes
Chrome 5.0.342.9 Other loop 1 Yes
Chrome 5.0.342.9 Windows 5.1 loop 1 Yes
Chrome 5.0.342.9 Windows 6.1 loop 1 Yes
Chrome 5.0.366.2 Windows 5.1 loop 1 Yes
Chrome 5.0.375.125 Windows 5.1 flash 1 Yes
Chrome 5.0.375.125 Windows 5.1 java 1 Yes
Chrome 5.0.375.125 Windows 5.1 loop 1 Yes
Chrome 5.0.375.125 Windows 5.1 XMLhttp 1 Yes
Chrome 5.0.375.29 Windows 6.1 loop 1 Yes
Chrome 5.0.375.38 Macintosh 10_5_8 flash 1 Yes
Chrome 5.0.375.38 Macintosh 10_5_8 loop 1 Yes
Chrome 5.0.375.38 Macintosh 10_5_8 XMLhttp 1 Yes
Chrome 5.0.375.38 Macintosh 10_6_3 XMLhttp 1 Yes
Chrome 5.0.375.38 Windows 5.1 loop 1 Yes
Chrome 5.0.375.55 Macintosh 10_5_8 XMLhttp 1 Yes
Chrome 5.0.375.55 Macintosh 10_6_3 loop 1 Yes
Chrome 5.0.375.55 Windows 5.1 loop 1 Yes
Chrome 5.0.375.55 Windows 5.1 XMLhttp 1 Yes
Chrome 5.0.375.55 Windows 6.1 loop 1 Yes
Chrome 5.0.375.6 Macintosh 10_6_3 flash 1 Yes
Chrome 5.0.375.6 Macintosh 10_6_3 loop 1 Yes
Chrome 5.0.375.6 Macintosh 10_6_3 XMLhttp 1 Yes
Chrome 5.0.375.7 Windows 5.1 loop 1 Yes
Chrome 5.0.375.70 Macintosh 10_6_3 loop 1 Yes
Chrome 5.0.375.70 Windows 5.1 flash 1 Yes
Chrome 5.0.375.70 Windows 5.1 java 1 Yes
Chrome 5.0.375.70 Windows 5.1 loop 1 Yes
Chrome 5.0.375.70 Windows 5.1 XMLhttp 1 Yes
Chrome 5.0.375.70 Windows 6.1 loop 1 Yes
Chrome 5.0.375.86 Windows 5.1 loop 1 Yes
Chrome 5.0.375.86 Windows 5.1 XMLhttp 1 Yes
Chrome 5.0.375.86 Windows 6.1 loop 1 Yes
Chrome 5.0.375.99 Macintosh 10_6_0 loop 1 Yes
Chrome 5.0.375.99 Macintosh 10_6_4 java 1 Yes
Chrome 5.0.375.99 Macintosh 10_6_4 loop 1 Yes
Chrome 5.0.375.99 Other loop 1 Yes
Chrome 5.0.375.99 Other XMLhttp 1 Yes
Chrome 5.0.375.99 Windows 5.1 flash 1 Yes
Chrome 5.0.375.99 Windows 5.1 java 1 Yes
Chrome 5.0.375.99 Windows 5.1 loop 1 Yes
Chrome 5.0.375.99 Windows 5.1 XMLhttp 1 Yes
Chrome 5.0.375.99 Windows 6.0 loop 1 Yes
Chrome 5.0.375.99 Windows 6.1 flash 1 Yes
Chrome 5.0.375.99 Windows 6.1 java 1 Yes
Chrome 5.0.375.99 Windows 6.1 loop 1 Yes
Chrome 5.0.375.99 Windows 6.1 XMLhttp 1 Yes
Chrome 5.0.381 Windows 5.1 java 1 Yes
Chrome 6.0.401.1 Windows 6.1 loop 1 Yes
Chrome 6.0.413.0 Linux i686 loop 1 Yes
Chrome 6.0.413.0 Linux i686 XMLhttp 1 Yes
Chrome 6.0.422.0 Linux i686 loop 1 Yes
Chrome 6.0.457.0 Other loop 1 Yes
Chrome 6.0.466.4 Macintosh 10_6_4 loop 1 Yes
Chrome 6.0.472.4 Macintosh 10_6_4 java 1 Yes
Firefox 2.0.0.13 Windows 6.0 loop 1 Yes
Firefox 2.0.0.20 Windows 5.1 java 2 Yes
Firefox 2.0.0.20 Windows 5.1 loop 2 Yes
Firefox 2.0.0.8 Windows 5.1 java 1 No
Firefox 2.0.0.8 Windows 5.1 loop 1 Yes
Firefox 2.0.0.8 Windows 5.1 XMLhttp 1 Yes
Firefox 3.0 Windows 5.1 loop 1 Yes
Firefox 3.0 Windows 6.1 java 1 No
Firefox 3.0.10 Windows 5.1 loop 1 Yes
Firefox 3.0.11 Windows 5.1 java 1 Yes
Firefox 3.0.11 Windows 5.1 loop 1 Yes
Firefox 3.0.11 Windows 6.0 java 1 No
Firefox 3.0.11 Windows 6.0 loop 1 Yes
Firefox 3.0.11 Windows 6.0 XMLhttp 1 No
Firefox 3.0.12 Windows 6.0 java 1 No
Firefox 3.0.12 Windows 6.0 loop 1 Yes
Firefox 3.0.13 Ubuntu 8.04 loop 1 Yes
Firefox 3.0.13 Windows 5.1 java 2 No
Firefox 3.0.13 Windows 5.1 java 1 Yes
Firefox 3.0.13 Windows 5.1 loop 2 Yes
Firefox 3.0.13 Windows 5.1 XMLhttp 1 No
Firefox 3.0.14 Ubuntu 8.04 loop 1 Yes
Firefox 3.0.14 Ubuntu 9.04 java 1 Yes
Firefox 3.0.14 Ubuntu 9.04 XMLhttp 1 No
Firefox 3.0.14 Windows 5.1 flash 1 Yes
Firefox 3.0.14 Windows 5.1 java 1 Yes
Firefox 3.0.14 Windows 5.1 loop 6 Yes
Firefox 3.0.14 Windows 5.1 XMLhttp 2 No
Firefox 3.0.15 Ubuntu 8.04 loop 1 Yes
Firefox 3.0.15 Ubuntu 8.04 XMLhttp 1 No
Firefox 3.0.15 Ubuntu 8.04 XMLhttp 1 Yes
Firefox 3.0.15 Ubuntu 9.04 loop 2 Yes
Firefox 3.0.15 Windows 5.1 flash 1 Yes
Firefox 3.0.15 Windows 5.1 loop 2 Yes
Firefox 3.0.15 Windows 5.1 XMLhttp 2 No
Firefox 3.0.15 Windows 6.0 java 1 No
Firefox 3.0.15 Windows 6.1 flash 1 Yes
Firefox 3.0.15 Windows 6.1 loop 1 Yes
Firefox 3.0.15 Windows 6.1 XMLhttp 1 No
Firefox 3.0.16 Windows 5.1 XMLhttp 1 No
Firefox 3.0.17 Windows 5.1 java 2 No
Firefox 3.0.17 Windows 5.1 loop 1 Yes
Firefox 3.0.17 Windows 5.2 loop 1 Yes
Firefox 3.0.17 Windows 5.2 XMLhttp 1 No
Firefox 3.0.17 Windows 5.2 XMLhttp 1 Yes
Firefox 3.0.17 Windows 6.0 java 1 No
Firefox 3.0.18 Windows 6.0 loop 1 Yes
Firefox 3.0.19 Ubuntu 8.04 loop 1 Yes
Firefox 3.0.19 Ubuntu 9.04 java 1 Yes
Firefox 3.0.19 Windows 5.0 loop 1 Yes
Firefox 3.0.19 Windows 5.1 loop 2 Yes
Firefox 3.0.19 Windows 5.1 XMLhttp 2 No
Firefox 3.0.3 Windows 5.1 XMLhttp 1 No
Firefox 3.0.4 Windows 5.1 flash 1 Yes
Firefox 3.0.5 Linux i686 loop 1 Yes
Firefox 3.0.7 Windows 5.1 java 1 No
Firefox 3.0.7 Windows 6.0 java 1 No
Firefox 3.0.8 Windows 5.1 XMLhttp 1 No
Firefox 3.1 Other java 1 Yes
Firefox 3.5 Windows 5.1 loop 2 Yes
Firefox 3.5 Windows 5.1 XMLhttp 1 Yes
Firefox 3.5.1 Windows 5.1 java 1 No
Firefox 3.5.1 Windows 5.1 XMLhttp 1 Yes
Firefox 3.5.10 Windows 5.1 flash 2 Yes
Firefox 3.5.10 Windows 5.1 java 1 No
Firefox 3.5.10 Windows 5.1 loop 3 Yes
Firefox 3.5.10 Windows 5.1 XMLhttp 1 Yes
Firefox 3.5.11 Windows 6.1 XMLhttp 1 Yes
Firefox 3.5.2 Windows 5.1 java 2 No
Firefox 3.5.2 Windows 5.1 java 1 Yes
Firefox 3.5.2 Windows 5.1 loop 1 Yes
Firefox 3.5.2 Windows 5.1 XMLhttp 4 Yes
Firefox 3.5.2 Windows 6.0 java 1 No
Firefox 3.5.2 Windows 6.0 loop 1 Yes
Firefox 3.5.2 Windows 6.0 XMLhttp 1 Yes
Firefox 3.5.3 Linux i686 loop 2 Yes
Firefox 3.5.3 Linux i686 XMLhttp 1 Yes
Firefox 3.5.3 Macintosh 10 java 1 No
Firefox 3.5.3 Macintosh 10 loop 1 Yes
Firefox 3.5.3 Ubuntu 9.10 loop 1 Yes
Firefox 3.5.3 Windows 5.1 flash 1 Yes
Firefox 3.5.3 Windows 5.1 java 5 No
Firefox 3.5.3 Windows 5.1 java 1 Yes
Firefox 3.5.3 Windows 5.1 loop 7 Yes
Firefox 3.5.3 Windows 5.1 XMLhttp 5 Yes
Firefox 3.5.3 Windows 5.2 loop 2 Yes
Firefox 3.5.3 Windows 5.2 XMLhttp 1 Yes
Firefox 3.5.3 Windows 6.0 loop 1 Yes
Firefox 3.5.3 Windows 6.1 flash 1 Yes
Firefox 3.5.3 Windows 6.1 java 2 No
Firefox 3.5.3 Windows 6.1 loop 3 Yes
Firefox 3.5.3 Windows 6.1 XMLhttp 2 Yes
Firefox 3.5.4 Macintosh 10 java 1 No
Firefox 3.5.4 Ubuntu 9.10 loop 1 Yes
Firefox 3.5.4 Ubuntu 9.10 XMLhttp 1 Yes
Firefox 3.5.4 Windows 5.1 flash 1 Yes
Firefox 3.5.4 Windows 5.1 java 1 No
Firefox 3.5.4 Windows 5.1 java 1 Yes
Firefox 3.5.4 Windows 5.1 loop 3 Yes
Firefox 3.5.4 Windows 5.1 XMLhttp 1 Yes
Firefox 3.5.4 Windows 6.0 flash 1 Yes
Firefox 3.5.4 Windows 6.1 java 1 No
Firefox 3.5.4 Windows 6.1 loop 1 Yes
Firefox 3.5.4 Windows 6.1 XMLhttp 1 Yes
Firefox 3.5.5 Macintosh 10 java 2 No
Firefox 3.5.5 Macintosh 10 java 1 Yes
Firefox 3.5.5 Macintosh 10 loop 1 Yes
Firefox 3.5.5 Ubuntu 9.10 java 2 Yes
Firefox 3.5.5 Ubuntu 9.10 loop 3 Yes
Firefox 3.5.5 Ubuntu 9.10 XMLhttp 4 Yes
Firefox 3.5.5 Windows 5.1 flash 4 Yes
Firefox 3.5.5 Windows 5.1 java 6 No
Firefox 3.5.5 Windows 5.1 loop 9 Yes
Firefox 3.5.5 Windows 5.1 XMLhttp 4 Yes
Firefox 3.5.5 Windows 5.2 loop 1 Yes
Firefox 3.5.5 Windows 6.0 java 4 No
Firefox 3.5.5 Windows 6.0 java 1 Yes
Firefox 3.5.5 Windows 6.0 loop 1 Yes
Firefox 3.5.5 Windows 6.0 XMLhttp 1 Yes
Firefox 3.5.5 Windows 6.1 java 1 No
Firefox 3.5.5 Windows 6.1 loop 2 Yes
Firefox 3.5.6 Linux i686 flash 1 Yes
Firefox 3.5.6 Linux i686 java 2 Yes
Firefox 3.5.6 Linux i686 loop 4 Yes
Firefox 3.5.6 Linux i686 XMLhttp 1 Yes
Firefox 3.5.6 Macintosh 10 flash 2 Yes
Firefox 3.5.6 Macintosh 10 java 2 No
Firefox 3.5.6 Macintosh 10 loop 3 Yes
Firefox 3.5.6 Macintosh 10 XMLhttp 2 Yes
Firefox 3.5.6 Ubuntu 9.10 loop 1 Yes
Firefox 3.5.6 Windows 5.1 flash 1 Yes
Firefox 3.5.6 Windows 5.1 java 1 No
Firefox 3.5.6 Windows 5.1 loop 5 Yes
Firefox 3.5.6 Windows 5.1 XMLhttp 1 Yes
Firefox 3.5.6 Windows 5.2 loop 1 Yes
Firefox 3.5.6 Windows 6.1 XMLhttp 1 Yes
Firefox 3.5.7 Linux i686 java 1 Yes
Firefox 3.5.7 Linux i686 loop 1 Yes
Firefox 3.5.7 Macintosh 10 loop 1 Yes
Firefox 3.5.7 Ubuntu 9.10 java 1 Yes
Firefox 3.5.7 Ubuntu 9.10 loop 1 Yes
Firefox 3.5.7 Ubuntu 9.10 XMLhttp 1 Yes
Firefox 3.5.7 Windows 5.1 flash 4 Yes
Firefox 3.5.7 Windows 5.1 java 4 No
Firefox 3.5.7 Windows 5.1 java 4 Yes
Firefox 3.5.7 Windows 5.1 loop 9 Yes
Firefox 3.5.7 Windows 5.1 XMLhttp 7 Yes
Firefox 3.5.7 Windows 5.2 flash 1 Yes
Firefox 3.5.7 Windows 6.0 1 No
Firefox 3.5.7 Windows 6.0 flash 1 Yes
Firefox 3.5.7 Windows 6.0 loop 2 Yes
Firefox 3.5.7 Windows 6.0 XMLhttp 3 Yes
Firefox 3.5.7 Windows 6.1 flash 1 Yes
Firefox 3.5.7 Windows 6.1 java 3 No
Firefox 3.5.7 Windows 6.1 java 1 Yes
Firefox 3.5.7 Windows 6.1 loop 3 Yes
Firefox 3.5.8 Linux i686 XMLhttp 1 Yes
Firefox 3.5.8 Ubuntu 9.10 flash 1 Yes
Firefox 3.5.8 Ubuntu 9.10 java 1 Yes
Firefox 3.5.8 Ubuntu 9.10 loop 3 Yes
Firefox 3.5.8 Ubuntu 9.10 XMLhttp 2 Yes
Firefox 3.5.8 Windows 5.1 flash 2 Yes
Firefox 3.5.8 Windows 5.1 java 4 No
Firefox 3.5.8 Windows 5.1 java 2 Yes
Firefox 3.5.8 Windows 5.1 loop 4 Yes
Firefox 3.5.8 Windows 5.1 XMLhttp 2 Yes
Firefox 3.5.8 Windows 6.0 flash 2 Yes
Firefox 3.5.8 Windows 6.0 java 2 No
Firefox 3.5.8 Windows 6.0 loop 2 Yes
Firefox 3.5.8 Windows 6.0 XMLhttp 2 Yes
Firefox 3.5.9 Linux i686 XMLhttp 1 Yes
Firefox 3.5.9 Macintosh 10 java 1 No
Firefox 3.5.9 Macintosh 10 loop 1 Yes
Firefox 3.5.9 Ubuntu 9.10 java 1 Yes
Firefox 3.5.9 Ubuntu 9.10 loop 5 Yes
Firefox 3.5.9 Windows 5.1 java 2 No
Firefox 3.5.9 Windows 5.1 java 1 Yes
Firefox 3.5.9 Windows 5.1 loop 1 Yes
Firefox 3.5.9 Windows 5.1 XMLhttp 2 Yes
Firefox 3.5.9 Windows 5.2 loop 1 Yes
Firefox 3.5.9 Windows 6.1 flash 1 Yes
Firefox 3.5.9 Windows 6.1 loop 1 Yes
Firefox 3.5.9 Windows 6.1 XMLhttp 1 Yes
Firefox 3.6 Linux i686 loop 1 Yes
Firefox 3.6 Macintosh 10 loop 3 Yes
Firefox 3.6 Macintosh 10 XMLhttp 1 Yes
Firefox 3.6 Other loop 1 Yes
Firefox 3.6 Other XMLhttp 1 Yes
Firefox 3.6 Windows 5.1 flash 2 Yes
Firefox 3.6 Windows 5.1 java 5 No
Firefox 3.6 Windows 5.1 java 1 Yes
Firefox 3.6 Windows 5.1 loop 9 Yes
Firefox 3.6 Windows 5.1 XMLhttp 2 Yes
Firefox 3.6 Windows 5.2 loop 1 Yes
Firefox 3.6 Windows 6.0 loop 1 Yes
Firefox 3.6 Windows 6.0 XMLhttp 1 Yes
Firefox 3.6 Windows 6.1 flash 2 Yes
Firefox 3.6 Windows 6.1 java 4 No
Firefox 3.6 Windows 6.1 loop 1 Yes
Firefox 3.6 Windows 6.1 XMLhttp 2 Yes
Firefox 3.6.2 Macintosh 10 loop 1 Yes
Firefox 3.6.2 Windows 5.1 loop 2 Yes
Firefox 3.6.2 Windows 5.1 XMLhttp 1 Yes
Firefox 3.6.2 Windows 6.1 flash 1 Yes
Firefox 3.6.2 Windows 6.1 java 1 No
Firefox 3.6.2 Windows 6.1 XMLhttp 1 Yes
Firefox 3.6.3 Linux i686 flash 1 Yes
Firefox 3.6.3 Linux i686 java 1 Yes
Firefox 3.6.3 Linux i686 loop 2 Yes
Firefox 3.6.3 Linux i686 XMLhttp 1 Yes
Firefox 3.6.3 Macintosh 10 java 1 No
Firefox 3.6.3 Macintosh 10 loop 5 Yes
Firefox 3.6.3 Other flash 1 Yes
Firefox 3.6.3 Other java 2 Yes
Firefox 3.6.3 Other loop 1 Yes
Firefox 3.6.3 Other XMLhttp 1 Yes
Firefox 3.6.3 Ubuntu 10.04 loop 3 Yes
Firefox 3.6.3 Windows 5.1 flash 3 Yes
Firefox 3.6.3 Windows 5.1 java 7 No
Firefox 3.6.3 Windows 5.1 java 1 Yes
Firefox 3.6.3 Windows 5.1 loop 20 Yes
Firefox 3.6.3 Windows 5.1 XMLhttp 13 Yes
Firefox 3.6.3 Windows 5.2 loop 1 Yes
Firefox 3.6.3 Windows 6.0 flash 1 Yes
Firefox 3.6.3 Windows 6.0 java 5 No
Firefox 3.6.3 Windows 6.0 loop 5 Yes
Firefox 3.6.3 Windows 6.0 XMLhttp 2 Yes
Firefox 3.6.3 Windows 6.1 flash 3 Yes
Firefox 3.6.3 Windows 6.1 java 6 No
Firefox 3.6.3 Windows 6.1 loop 9 Yes
Firefox 3.6.3 Windows 6.1 XMLhttp 8 Yes
Firefox 3.6.4 Windows 5.1 java 1 No
Firefox 3.6.4 Windows 5.1 XMLhttp 1 Yes
Firefox 3.6.4 Windows 6.1 flash 1 Yes
Firefox 3.6.4 Windows 6.1 java 1 No
Firefox 3.6.4 Windows 6.1 loop 1 Yes
Firefox 3.6.4 Windows 6.1 XMLhttp 2 Yes
Firefox 3.6.6 Linux i686 loop 1 Yes
Firefox 3.6.6 Macintosh 10 flash 1 Yes
Firefox 3.6.6 Macintosh 10 java 1 No
Firefox 3.6.6 Macintosh 10 loop 4 Yes
Firefox 3.6.6 Macintosh 10 XMLhttp 2 Yes
Firefox 3.6.6 Ubuntu 10.04 loop 2 Yes
Firefox 3.6.6 Ubuntu 10.04 XMLhttp 1 Yes
Firefox 3.6.6 Windows 5.1 flash 2 Yes
Firefox 3.6.6 Windows 5.1 java 4 No
Firefox 3.6.6 Windows 5.1 java 1 Yes
Firefox 3.6.6 Windows 5.1 loop 9 Yes
Firefox 3.6.6 Windows 5.1 XMLhttp 3 Yes
Firefox 3.6.6 Windows 5.2 java 1 No
Firefox 3.6.6 Windows 6.0 java 1 No
Firefox 3.6.6 Windows 6.0 loop 1 Yes
Firefox 3.6.6 Windows 6.1 java 1 No
Firefox 3.6.6 Windows 6.1 loop 4 Yes
Firefox 3.6.6 Windows 6.1 XMLhttp 2 Yes
Firefox 3.6.7 Linux i686 java 1 No
Firefox 3.6.7 Macintosh 10 java 1 No
Firefox 3.6.7 Macintosh 10 loop 1 Yes
Firefox 3.6.7 Ubuntu 10.04 loop 1 Yes
Firefox 3.6.7 Windows 5.1 loop 3 Yes
Firefox 3.6.7 Windows 6.1 XMLhttp 1 Yes
Firefox 3.6.8 Linux i686 flash 1 Yes
Firefox 3.6.8 Linux i686 java 1 No
Firefox 3.6.8 Linux i686 loop 1 Yes
Firefox 3.6.8 Linux i686 XMLhttp 1 Yes
Firefox 3.6.8 Macintosh 10 loop 1 Yes
Firefox 3.6.8 Windows 5.1 java 1 No
Firefox 3.6.8 Windows 5.1 loop 2 Yes
Firefox 3.6.8 Windows 6.1 flash 1 Yes
Firefox 3.6.8 Windows 6.1 java 1 No
Firefox 3.6.8 Windows 6.1 loop 1 Yes
Firefox 3.6.8 Windows 6.1 XMLhttp 1 Yes
Iceweasel 2.0.0.19 Debian 2.0.0.19-0 loop 1 Yes
Iceweasel 3.0.6 Debian 3.0.6-3 loop 1 Yes
Iceweasel 3.5.3 Debian 3.5.3-1 java 1 Yes
Iceweasel 3.5.3 Debian 3.5.3-1 loop 1 Yes
Iceweasel 3.5.3 Debian 3.5.3-1 XMLhttp 1 Yes
MSIE 6.0 Windows 5.0 java 1 Yes
MSIE 6.0 Windows 5.0 loop 1 Yes
MSIE 6.0 Windows 5.0 XMLhttp 2 Yes
MSIE 6.0 Windows 5.1 1 No
MSIE 6.0 Windows 5.1 flash 2 Yes
MSIE 6.0 Windows 5.1 java 7 No
MSIE 6.0 Windows 5.1 java 9 Yes
MSIE 6.0 Windows 5.1 loop 15 Yes
MSIE 6.0 Windows 5.1 XMLhttp 12 Yes
MSIE 6.0 Windows 5.2 XMLhttp 2 Yes
MSIE 6.0 Windows 98 flash 1 Yes
MSIE 7.0 Windows 5.1 1 No
MSIE 7.0 Windows 5.1 flash 7 Yes
MSIE 7.0 Windows 5.1 java 17 No
MSIE 7.0 Windows 5.1 java 6 Yes
MSIE 7.0 Windows 5.1 loop 20 Yes
MSIE 7.0 Windows 5.1 XMLhttp 19 Yes
MSIE 7.0 Windows 5.2 loop 1 Yes
MSIE 7.0 Windows 6.0 flash 1 Yes
MSIE 7.0 Windows 6.0 java 2 No
MSIE 7.0 Windows 6.0 java 1 Yes
MSIE 7.0 Windows 6.0 loop 5 Yes
MSIE 7.0 Windows 6.1 XMLhttp 1 Yes
MSIE 8.0 Windows 5.1 1 No
MSIE 8.0 Windows 5.1 flash 5 Yes
MSIE 8.0 Windows 5.1 java 8 No
MSIE 8.0 Windows 5.1 java 4 Yes
MSIE 8.0 Windows 5.1 loop 22 Yes
MSIE 8.0 Windows 5.1 XMLhttp 15 Yes
MSIE 8.0 Windows 5.2 flash 1 Yes
MSIE 8.0 Windows 5.2 java 1 No
MSIE 8.0 Windows 5.2 loop 2 Yes
MSIE 8.0 Windows 6.0 flash 4 Yes
MSIE 8.0 Windows 6.0 java 10 No
MSIE 8.0 Windows 6.0 java 3 Yes
MSIE 8.0 Windows 6.0 loop 15 Yes
MSIE 8.0 Windows 6.0 XMLhttp 9 Yes
MSIE 8.0 Windows 6.1 1 No
MSIE 8.0 Windows 6.1 flash 4 Yes
MSIE 8.0 Windows 6.1 java 5 No
MSIE 8.0 Windows 6.1 java 1 Yes
MSIE 8.0 Windows 6.1 loop 15 Yes
MSIE 8.0 Windows 6.1 XMLhttp 12 Yes
Opera 9.52 Linux i686 loop 1 Yes
Opera 9.52 Linux i686 XMLhttp 1 Yes
Opera 9.64 Windows 5.1 java 2 Yes
Opera 9.64 Windows 5.1 loop 1 Yes
Opera 9.64 Windows 6.0 java 1 Yes
Opera 9.64 Windows 6.0 loop 1 Yes
Opera 9.64 Windows 6.0 XMLhttp 1 Yes
Opera 9.64 Windows 6.1 flash 1 Yes
Opera 9.80 Macintosh 2 flash 1 Yes
Opera 9.80 Macintosh 2 java 1 Yes
Opera 9.80 Macintosh 2 loop 2 Yes
Opera 9.80 Macintosh 2 XMLhttp 1 Yes
Opera 9.80 Other loop 1 Yes
Opera 9.80 Windows 5.1 java 1 Yes
Opera 9.80 Windows 5.1 loop 9 Yes
Opera 9.80 Windows 5.1 XMLhttp 2 Yes
Opera 9.80 Windows 6.0 XMLhttp 2 Yes
Opera 9.80 Windows 6.1 java 1 Yes
Opera 9.80 Windows 6.1 loop 4 Yes
Opera 9.80 Windows 6.1 XMLhttp 1 Yes
Other Other 8 No
Other Other flash 1 Yes
Other Other loop 1 Yes
Other Other XMLhttp 1 Yes
Other Ubuntu 9.10 java 1 Yes
Other Ubuntu 9.10 loop 1 Yes
Other Ubuntu 9.10 XMLhttp 1 Yes
Other Windows 5.1 flash 1 Yes
Other Windows 5.1 java 1 Yes
Other Windows 5.1 loop 1 Yes
Other Windows 5.1 XMLhttp 1 Yes
Safari 525.13.3 Windows 5.1 java 1 Yes
Safari 525.13.3 Windows 5.1 loop 1 Yes
Safari 525.13.3 Windows 5.1 XMLhttp 1 Yes
Safari 525.20.1 Macintosh 10_5_5 XMLhttp 1 Yes
Safari 525.27.1 Macintosh 10_4_11 loop 1 Yes
Safari 528.16 Other XMLhttp 1 Yes
Safari 531.21.10 Macintosh 10_4_11 java 1 Yes
Safari 531.21.10 Macintosh 10_5_8 flash 1 Yes
Safari 531.21.10 Macintosh 10_5_8 java 1 Yes
Safari 531.21.10 Macintosh 10_5_8 loop 1 Yes
Safari 531.21.10 Macintosh 10_5_8 XMLhttp 1 Yes
Safari 531.21.10 Macintosh 10_6_2 java 2 Yes
Safari 531.21.10 Macintosh 10_6_2 loop 2 Yes
Safari 531.21.10 Macintosh 10_6_2 XMLhttp 1 Yes
Safari 531.21.10 Windows 5.1 flash 1 Yes
Safari 531.21.10 Windows 5.1 loop 1 Yes
Safari 531.21.10 Windows 5.1 XMLhttp 1 Yes
Safari 531.21.10 Windows 6.0 flash 1 Yes
Safari 531.21.10 Windows 6.0 java 1 Yes
Safari 531.21.10 Windows 6.0 loop 1 Yes
Safari 531.21.10 Windows 6.0 XMLhttp 1 Yes
Safari 531.22.7 Macintosh 10_5_8 loop 1 Yes
Safari 531.22.7 Macintosh 10_6_2 flash 1 Yes
Safari 531.22.7 Macintosh 10_6_2 java 1 Yes
Safari 531.22.7 Macintosh 10_6_2 loop 1 Yes
Safari 531.22.7 Macintosh 10_6_3 flash 1 Yes
Safari 531.22.7 Macintosh 10_6_3 java 1 Yes
Safari 531.22.7 Macintosh 10_6_3 loop 2 Yes
Safari 531.22.7 Macintosh 10_6_3 XMLhttp 1 Yes
Safari 531.22.7 Windows 6.1 loop 1 Yes
Safari 531.9 Macintosh 10_6_1 loop 1 Yes
Safari 531.9 Macintosh 10_6_1 XMLhttp 1 Yes
Safari 531.9 Macintosh 10_6_2 java 1 Yes
Safari 531.9 Macintosh 10_6_2 XMLhttp 1 Yes
Safari 531.9.1 Windows 5.1 loop 1 Yes
Safari 531.9.1 Windows 6.0 java 1 Yes
Safari 531.9.1 Windows 6.0 loop 1 Yes
Safari 531.9.1 Windows 6.0 XMLhttp 1 Yes
Safari 531.9.1 Windows 6.1 flash 1 Yes
Safari 531.9.1 Windows 6.1 java 1 Yes
Safari 533.16 Macintosh 10_6_3 java 1 Yes
Safari 533.16 Macintosh 10_6_4 java 2 Yes
Safari 533.16 Macintosh 10_6_4 loop 3 Yes
Shiretoko 3.5.2 Ubuntu 9.04 XMLhttp 1 Yes
Shiretoko 3.5.3 Ubuntu 9.04 loop 1 Yes
(This list is automatically generated from the "Test my Browser" buttons on each examples web page. So please contribute to this list by testing your browser with each of our examples. Currently 1071 tests are included.)

P. S. The reason that JavaScript freezes the browser while sleeping is because it only runs as a single thread.

P. S. S. There are a few other javascript sleep implementations that could be used (Workers for example) but I have choosen to only provide examples that will run on all major browsers. These may freeze the browser but still run on them all.


Newsletter and Contact Form

Please signup for our newsletter in order to be notified whenever updates are made to this site.
As always, any corrections, comments or suggestions are greatly appreciated.

Newsletter
Enter code
Your Name
Your Email
Subject
Your Message

© Copyright 2010 All Rights Reserved

DevCheater software is licensed under LGPL 3 and free of charge.