Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide everything on dom until everything is loaded

I am trying to change the content of a div on the page but the page has a lot of things to load and on slower computers there is a flicker where you can see the div changing (changing through jquery btw). Is there anyway that everything can be hidden and display it all at including the changes I made using jquery?

like image 219
Chris Avatar asked Dec 22 '13 12:12

Chris


People also ask

How do I hide the DOM element?

Style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery. To hide an element, set the style display property to “none”.

How do you check DOM is loaded or not?

Use document. readyState === 'interactive' to detect when the DOM is ready.

Which of the following code snippet is used to hold some content that will be hidden when page loads?

The <template> tag is used as a container to hold some HTML content hidden from the user when the page loads.


1 Answers

I had a similar issue with my web application.. This is what I did

Hide body in HTML

<body style="display:none">

And write this script :

$(window).bind("load", function() {
   $("body").fadeIn(100);
});

OR this script

$(window).load(function () {
   $("body").fadeIn(100);
}

This creates beautiful effect and shows the page ONLY after everything is fully loaded..

like image 66
Rahul Patil Avatar answered Oct 07 '22 02:10

Rahul Patil