Javascript: Animation lag