Created
November 17, 2016 15:04
-
-
Save jonathanbaker7/71e9cf558b3c6100d156803438fbb387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<body> | |
<h2>Testing the events queue in a browser</h2> | |
<p>The event queue is single threaded, so anything currently running blocks all other | |
events. This includes JavaScript, page rendering, and any user input</p> | |
<p>To test this, click on the “Go” button. Watch the input boxes, as they are being updated in each loop. The rendering, however, is on hold, so the changes don’t appear.</p> | |
<p>While the loop is running, you can also click the browser refresh button. Nothing will happen until the loop completes!</p> | |
<form> | |
<span>Current loop iterations:</span> | |
<br/> | |
X Loop: <input id="x" type="text"></input> | |
<br/> | |
Y Loop: <input id="y" type="text"></input> | |
</form> | |
<br/><br/> | |
<button onclick="runloop()">Go</button> | |
<script type="text/javascript"> | |
console.log("Testing"); | |
var x = document.getElementById("x"); | |
var y = document.getElementById("y"); | |
function runloop() { | |
console.log("Starting the loop"); | |
for(var i=0; i<10000 ; i++ ) { | |
x.setAttribute("value", i); | |
console.log("Current X: " + x ); | |
for(var j=0; j < 1000 ; j++ ){ | |
y.setAttribute("value",j); | |
} | |
} | |
return false | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment