Submission + - Why doesn't javascript has a sleep/wait function?
sandeepbansal writes: "While executing a webpage in firefox which was a pretty printed version of a JSON feed produced with BeautifyJSON the browser became unresponsive for a long time due to the load of the javascript it was executing. When i decided to modify the script so that it is executed in small steps to increase browser responsiveness i couldn't come up with an elegant way as javascript has no inbuilt sleep/wait function. A similar thing even happens at slashdot. Try going to any story with more then 250 comments and then reducing the expanded comments to 0 and then increasing them to the maximum allowable limit. A user will not be seeing all the +250 comments at the same time and thus executing the script at small intervals would have been much more effective. I really cant understand why doesn't javascript has an inbuilt sleep/wait functionality? Granted javascript provides the setTimout function which can be used to rewrite the function to do the work properly but, is this the correct way? Having a native sleep/wait function would have been much nicer."