If you only need to "hide" the content of the site before the load
be fired, can use a class with this property that is inserting directly into the DOM, it is easier to manipulate:
.hide { display: none }
The content to be "hidden" while the page is loaded may initially have that class. Simply remove it when the load
is fired.
ps: I put an image for the load to take to be fired on a first load.
var loading = document.querySelector('div'),
content = document.querySelector('main');
window.onload = function() {
loading.classList.add('hide'); // esconde o 'carregando'.
content.classList.remove('hide'); // mostra o conteúdo do site.
};
.hide, img { display: none }
<div>
<p>carregando...</p>
</div>
<main class='hide'>
<img src='http://i.stack.imgur.com/uoKIw.jpg' />
conteúdo do site.
</main>
In the above example I used classList
but I already say that not all browsers have this feature implemented. Internet Explorer < 10 and Opera Mini 5 do not support the classList
- see browsers that support. Anyway in that reply there are possible solutions you can use.
If you want to display a progress bar as the site loads (showing the percentage), I suggest using the PACE for this.