title: Preloading images in image folder and sub directories within image folder
body: <p>I concocted a bit of jquery and php to preload images from an image folder. Our site has since grown and all portfolio images have been put in different folders within the main image directory. I need a way to preload these to make our portfolio quicker. Below is what I have so far.</p>
  
  <p>It loops through the images and puts them into a hidden div so they get cached.</p>
  
  <p>inside preload.php</p>
  
  <pre><code>&lt;div style="display:none"&gt;
  &lt;?php
   $dirf    = 'images';
   $dir = scandir($dirf);
   foreach($dir as $file) {
   if(($file!='..') &amp;&amp; ($file!='.')) {
         echo "&lt;img src='images/$file' /&gt;";
     }
   }
  ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I use a bit of jquery to put it on the page via the #preload div and get rid of it afterwards</p>
  
  <pre><code> $('#preload').load('preload.php', function () {
      $('#preload').remove();
  });
  </code></pre>