Page lifecycle event before "When Page Loads"?

Is there any event we can hook into before the “When Page Load” event? Most frameworks have an “initialize” or “Pre-page load” event where we can do security related redirects etc. I’ve searched the forum but can’t see any evidence that there is one - but i want to check!

I don’t want that big delay of my (quite heavy) home page and “flash of content” for un-authenticated users before they are redirected. My hacky workaround is to have a fake homepage that has nothing on it and do the logic there - but I’d rather avoid this, because it’s a hack, and also Google punishes apps for initial page redirects (https://developers.google.com/speed/docs/insights/AvoidRedirects)

Thanks!

The home page is intended for un-authenticated users, could you rearrange pages to have this in mind?

For example, making the home page light, mostly static content, with a minimal check for authenticated users and redirect to the good stuff.

This is a sound way of doing things, but is does not however answer the question.
Is there a pre-loaded event available?

What if a non-authenticated user uses a direct link to a page from a browser shortcut or something? Then the page gets loaded does it not?
But with a lot of broken stuff on it of course.

I created a “fix” for this that redirects to index on the page-loaded event in the header element.
This does however “blink” the requested page before it gets redirected.
Hence the need for a pre-loaded event.

…or a hard redirect by bubble to some, in general configured page, for all non-authenticated users.

best regards
Alexander Moan

I’m very surprised that there isn’t an event before the page loads. Using page load to set state results in a lot of movement on the page on load (for example a sidebar opening in expanded mode and contracting once the state is read from the database on page load). Is there any other way to do this?