title: Is it possible to run javascript before images begin loading?
body: <p>I'd like to change the src attribute of images before they are requested by the browser, the aim being to reduce the size of the images using a PHP script like Timthumb. Using jQuery, I thought <code>$(document).ready</code> would do the trick:</p>
  
  <pre><code>$(document).ready(function () {
    var imgs = $('#container img');
    jQuery.each(imgs, function() {
      $(this).replaceWith('&lt;img src="timthumb/timthumb.php?src=' + $(this).attr('src') + '&amp;w=200" /&gt;');
      });
  });
  </code></pre>
  
  <p>But the original, unresized image is still downloaded in the background to the browser's cache. Is it possible to do what I'm trying to do on the client side, or is server-side the only option?</p>