Skip to content

Instantly share code, notes, and snippets.

@creinig
Created March 13, 2013 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creinig/5150747 to your computer and use it in GitHub Desktop.
Save creinig/5150747 to your computer and use it in GitHub Desktop.
HTML page that renders the browser unresponsive by blocking in a javascript function
<html>
<head>
<script type="text/javascript">
function burn(seconds) {
var start = (new Date()).getTime();
while(true) {
var now = (new Date()).getTime();
var duration = now - start;
if(duration > (seconds * 1000)) {
break;
}
}
}
</script>
</head>
<body>
<p>Burn for:</p>
<ul>
<li><a href="#" onclick="burn(2)">2 seconds</a></li>
<li><a href="#" onclick="burn(5)">5 seconds</a></li>
<li><a href="#" onclick="burn(10)">10 seconds</a></li>
<li><a href="#" onclick="burn(30)">30 seconds</a></li>
</ul>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment