Background tasks for JavaScript. Based on prior work by Gergő Érdi: http://gergo.erdi.hu/blog/2006-09-22-queueing_timeouts_in_javascript/