Why not just tie this into the scripts `onload` event?