<head>
<script>
if(condition){
window.location = "http://yournewlocation.com";
}
</script>
</head>
<body>
...
</body>
This will force the checking of condition and the change in url location before the page renders anything. It is worth noting that you will specifically want to do this before the call to the jQuery library so you can avoid all that library loading. Some might also argue that this would be better placed in a wrapper method and called so here is that method:
function redirectHandler(condition, url){
if(condition){
window.location = url;
}else{
return false;
}
}
That would allow you to check multiple conditions and redirect to different locations based on it:
if(redirectHandler(nologgedin, "/login.php")||redirectHandler(adminuser, "/admin.php"));
or if you only need it to run once and only once, but you like having nothing in the global namespace:
(function(condition, url){
if(condition)window.location=url;
})(!loggedin, "/login.asp");