I built a simple css preloader that should fade out with jQuery once the page has been completely loaded with all images etc.:
$(document).ready(function() {
// Preloader
$(window).on('load', function() {
$('#loader').delay(350).fadeOut('slow');
$('#preloader-bg').delay(1000).fadeOut('slow');
});
});
The problem is that the window load event is not reliably triggered inside the document ready function. Once the page has been cached it seems to work, but it is not triggered the first time the site is loaded.
Is there a workaround?