If you need a infinite process/recursion running for some reason, you can use a webworker in a seperate thread.
http://www.html5rocks.com/en/tutorials/workers/basics/
if you want to manipulate dom elements and redraw, use animation
http://creativejs.com/resources/requestanimationframe/