Fix race between updateToc and window.onload