Search code examples
jqueryhtmldelay

Loading Delay on offline html page


I have a overlay delay on my html page, if the page couldnt load fast enough.

HTML

<div class="loading" style="display: none; "></div>

CSS

.loading { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: 100000; 
    background: url(../img/loading.gif) no-repeat center center white;  
}

Script

jQuery(window).load(function() {
 //Image Hover Efect
 jQuery(".loading").fadeOut(1000);  
});

Any change to get a page load delay to check if the scipt is ok?


Solution

  • Instead of .load use .ready, like this:

    jQuery(document).ready(function() {
        //Image Hover Efect
        jQuery(".loading").fadeOut('fast');  
    });
    

    the .ready function is executed when the DOM is fully loaded.

    Greatings.