title: Javascript code only working after page refresh and not first viewing
body: <p>i am using a bit of javascript that checks all of my images for their width and adds a class depending.</p>
  
  <p>It looks like so:</p>
  
  <pre><code>$(document).ready(function(){
  // check each image in the .blogtest divs for their width. If its less than X make it full size, if not its poor and keep it normal
  var box = $(".blogtest");
  box.find("img.buildimage").each(function() {
     var img = $(this), width = img.width();
     if (width &gt;= 700) {
        img.addClass("buildimage-large");
     } else if (width &lt; 700) {
        img.addClass("buildimage-small");
     }
  }); 
  });
  </code></pre>
  
  <p>The issue is, the images dont have a class added to them when you first visit the page, instead they only work when you refresh the page.</p>
  
  <p>Any fix for this?</p>