Any reason not to combine your script with the following in Customize --> Themes --> Mobile --> Header?
<script>
if (window.location.pathname == "/")
{ window.location.href = "/latest";
}
</script>
This will handle the initial redirect to /latest if the user arrives on the homepage.