Just put the script in your page.
Put the script inside the <head>
tag or right before the opening of the <boby>
tag, this way it will correct the title instanctly, and the user won't notice. If you put in the end like the best practices says, it'll have a delay.