I'm swapping the content of a page via jQuery's .load()
For example, on page1.html
I have:
$('#wrapper').fadeOut(2500, function() {
$(this).load('page2.html', function() {
$(this).fadeIn(2500);
});
});
The page2.html
content contains some fairly large images, and I am attempting to preload them on page1.html
via $.get()
:
$.get('img/largeImage1.jpg');
$.get('img/largeImage2.jpg');
// etc...
From everything I've read, I'm doing this correctly. The problem is, in Firefox, when I attempt to display largeImage2.jpg for the first time (it's initially hidden with CSS), it appears ever-so-briefly as a broken image. The broken image isn't present when hardcoding in (or 'preloading' via a different method) the image tag on page2.html
, i.e. placing <img src="img/largeImage2.jpg" style="display: none;">
somewhere on the page.
Why doesn't the $.get()
method work? Am I doing something wrong? Why does Firefox show a broken image for a fraction of a second before loading it? Is jQuery's .load()
emptying out the browser's cache/buffer so my attempts at preloading are useless? What's going on?