Javascript performance tweaks