Queuing JavaScript tasks