JS – Hide all contents until all page is loaded ( only if javascript is enable )

March 28th, 2017

This time i need to hide website contents, until all contents are loaded.

I use a JS . jQuery solutions ..

 

 

Before open the

body

add this:

 document.documentElement.className = "js" 

This peace of code, check if javascript is enable and then add a class to

  

tag.
Now we can hide body whit out worries about that if someone see the website without javascript, all is disabled.

So we can add a class to our css like this one:


.js body{display:none;}

At the moment if javascript is enabled, all contents isn’t display ( contrary if javascript are disabled, all is visibile ).
Now add some little jquery code inside our .js file.

 


jQuery(window).load(function() {
jQuery("body").fadeIn("slow");
});

 

See the Pen JS – Hide all contents until all page is loaded ( only if javascript is enable ) by Pizzi (@Pizzi) on CodePen.dark