I am using the following approach to Preload the content of my website:
$(window).load(function(){
$('#preLoader').hide();
$('#container').show();
});
Now my #container div contains all my website content. I don't want this to be shown until my body background image has completely loaded...So while the background image is loaded, the #preLoader div displays with an animated loader gif inside.
The issue:
There are some elements that do not always load (eg gravatars) due to the Server containing the resource not being available...so the $(window).load()
function never executes since the page has not finished loading - it it stuck at trying to download a resource that is not available and keeps displaying the loader.
How do I ignore requests that takes too long to respond so that my load function can execute - hide the loader and show the content.
I do not want to use the $(document).ready()
function, since it does not wait until my background image has finished loading...