Obviously, the sooner the better. Don't make your server run any longer than it needs to before redirecting to a page of interest.
However, you don't always know what you want to redirect before the page load event, or even later - perhaps after handling the button click event.
source
to share