title: Check if preload script has already run (elements are in cache)
body: <p>I have this jQuery AJAX function that load with the call to .JS on every page in the html 
  
  <p>I would like to put an if statement that checks if the files that I want to preload are already in cache. This to avoid that the script will run all its content on every page.
  Once everything is in cache we don't need that. And is time consuming to run it!</p>
  
  <p>Note: I want it on every page because I want that preload where ever the client land to the web site. (not only main page)</p>
  
  <p>Here is the preload.js:</p>
  
  <pre><code>(function() {
  </code></pre>
  
  <p>here to insert the if statement, should be something like:</p>
  
  <pre><code>if(xhr[src="myslide.swf"].status = 200);
  alert('cached');
  </code></pre>
  
  <p>or (concept) if myslide.swf is in cache then do nothing; else...</p>
  
  <pre><code>}else{
  setTimeout(function(){
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'myslide.js');
  xhr.send('');   
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'myslide.swf');
  xhr.send('');
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'images.xml');
  xhr.send('');
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'param.xml');
  xhr.send('');
  $.ajax({ 
  type: "POST", 
  url: "/javascript/getnames.php", 
  data: "$list",
  cache: true,
  dataType:"json",
  success: function(result) {
      Object.size = function(obj) {
      var size = 0, key;
      for (key in obj) {
      if (obj.hasOwnProperty(key)) size++;
        }
       return size;
      };
      // Get the size of an object
      var size = Object.size(result);
      var i = 0;
      for(i=0; i&lt;size; i++) new Image().src = "/site/" + result[i];
                  /*alert(result[X]);*/
              }
       });  //closes the ajax call
  var splashArray = new Array();
  // Load the Splash XML file and assign each image within to an array
  $.get('/javascript/preloadGallery.xml', function(xml) {
      $('image', xml).each(function (i) {
              splashArray.push($(this).attr("src"));
      });
      work_with_splash();
  });
  function work_with_splash () {
      Object.size = function(obj) {
      var size = 0, key;
      for (key in obj) {
      if (obj.hasOwnProperty(key)) size++;
        }
       return size;
      };
      // Get the size of an object
      var size = Object.size(splashArray);
      var i = 0;
      for(i=0; i&lt;size; i++) new Image().src = splashArray[i];
                  /*alert(result[X]);*/   
  } //closes the spalsh Call
  }, 500);
  };
  
  })();   
  </code></pre>
  
  <p>All the script works perfectly, the only thing I miss is the if statement.</p>
  
  <p>Thanks for the help.</p>