Want more features on Pastebin? Sign Up, it's FREE!
Guest

Paul Irish recursive JS timeout test

By: DisasterMan on Apr 6th, 2011  |  syntax: HTML 5  |  size: 1.01 KB  |  views: 406  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <style type="text/css">
  7. #ickletest{ left:0px; top:0px; width: 100px; height: 100px; position:absolute; background: #f00; }
  8. </style>
  9. </head>
  10. <body>
  11. <div id="ickletest"></div>
  12.  
  13. <script type="application/javascript">
  14. <!--
  15. var start = new Date().getTime();
  16. testObj = document.getElementById('ickletest');
  17. testObj.style.left = '0px';
  18.  
  19. function move(){
  20.         testObj.style.left = parseInt(testObj.style.left)+10+'px';
  21.  
  22.         var elapsed = new Date().getTime() - start;
  23.         console.log('move: ' + elapsed);
  24. }
  25. function doStuff(){
  26.         setTimeout(move(),1000);;
  27. }
  28.  
  29. (function(){
  30.  
  31.         doStuff();
  32.  
  33.         setTimeout(arguments.callee,1500)
  34.  
  35.         var elapsed = new Date().getTime() - start;
  36.         console.log('loop: ' + elapsed);
  37. })()
  38. -->
  39. </script>
  40. </body>
  41. </html>
clone this paste RAW Paste Data