Check whether an image is in the cache?

Check whether an image is in the cache?

When using the function to switch images as shown below, I want to check if the image is already in the cache to prevent showing the css .loading class. The .complete() object just made a lot of trouble but I couldn't use it probably. 

The switchImage Function is fired when pressing a thumbnail or a prev/next button. Is their any solution to check whether the image/url I want to load is already in the cache?

  1. switchImage = function(){
  2. var currentPath = $active.attr("href");

  3. $('#largeImg').fadeOut('fast',loadContent);
  4.  
  5. $(".thumbs a").removeClass('active');
  6. $active.addClass('active');

  7. function loadContent() {
  8. $('.loading').fadeIn('fast');
  9. $("#largeImg").attr( "src", currentPath).load(function(){
  10. $('.loading').fadeOut('fast');
  11. $('#largeImg').fadeIn('normal');
  12. });
  13. }
  14. };