Wait until the HEAD is rendered before injecting a script into the head

@EamonNerbonne Please review this fix before pushing the update to the webstore.