wpdd
wpdd

Reputation: 456

Page reload once before loading any of the other content

I want to reload my site (only once) before loading any of the content. I implemented this option but the user is still able to see the content of the page before going for reload. Here is my code

window.onload = function() {
if(!window.location.hash) {
    window.location = window.location + '#loaded';
    window.location.reload();
}

}

How can I implement this functionality without showing any of the content to the site visitor.

Upvotes: 1

Views: 63

Answers (1)

Turner Houghton
Turner Houghton

Reputation: 506

You mean you don't want your user to see any of the content on the page before you trigger the reload?

If you mean 'see', like visually see the content, you could always put a div that blocks the entire viewport, and then remove it once the page has been reloaded.

But to me, this seems like an issue that could be resolved by not adding anything to the document body until your conditions have been met. You should design your code in such a way that a refresh is not needed, as that is creating unnecessary requests.

Upvotes: 3

Related Questions