I have this event handler for when the page is loading. It shows a preloader GIF image when the window start loading.

$(window).load(function(){
        $("#Preloader").css('display','block');
    });

But I don't know how to detect if the window stops loading so I can remove the preloader.
How to detect if the window stops loading?

You have to show the preloader with CSS and hide it with $(window).load(), when everything has been loaded.

$(window).load(function(){
    $("#Preloader").fadeOut(1000);
});

Hi gentlemedia,

I don't understand. Does $(window).load() also triggers when the window stop loading.
How does it work?

What you put inside the load() event will only get triggered once the DOM and all assets (such as images, videos, iframes or whatever else you have on yout page) is fully loaded. So that's the moment when you want to hide your loader or spinner.

http://api.jquery.com/load-event/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.