title: jQuery window resize doesn't work on iOS
body: <p>The site I'm working on is freezing on orientation change, which falls under the resize function. After a lot of rewriting, it would work with the resize event moved outside of the plug in. This resulted in other unwanted behavior, so it's not ideal.</p>
  
  <p>Any idea why it's getting stuck? Other plugins I know of, such as Supersized, run through doc ready, load, and resize in a similar way without the hang up.. So I know there's probably some little detail about how I wrote it that's causing it.</p>
  
  <p>Thaks for your help!</p>
  
  <p>Test site:
  <a href="http://brantley.dhut.ch/" rel="nofollow">http://brantley.dhut.ch/</a></p>
  
  <p>JavaScript:</p>
  
  <p>Plug in-</p>
  
  <pre><code>(function( $ ){
      $.fn.respond = function(callback) {
  
          /* initialize function on window load and resize */
          $(document).ready(function() {
              dimensions();
          });
          $(window).resize(function() {
              dimensions();
          });
  
          /* declare affected elements */
          var pic = this
  
          /* set image's height or width depending on the browser window's size */
          function dimensions() {
              return pic.each(function() {
  
              /* declare variables */
                  var browserWidth = $(window).width();
                  var imgRatio = $(this).width() / $(this).height()
                  var availableHeight = ($(window).height() - $('header').height() - $('footer').height() - 80)
                  var browserRatio = browserWidth / availableHeight
  
                  /* image sizing logic */
                  if (browserRatio &gt;= imgRatio) {
                      if (browserWidth &gt; 640) {
                          /* if the browser is landscape and bigger than mobile, set the image's height to fill the available space */
                          $(this).height(availableHeight).width('auto');
                          //$('body').css('background', 'blue');
                      } else {
                          /* it's mobile */
                          $(this).width(browserWidth - 40).height('auto');
                          //$('body').css('background', 'red');
                      }
                  } else {
                      /* if the browser is portrait, set the image's width to fill the page */
                      $(this).width(browserWidth - 40).height('auto');
                      //$('body').css('background', 'green');
                  }
  
                  /* horizontally center content */
                  $(this).css('margin-left', (browserWidth - $(this).width())/2);
  
              });
  
          };
          callback();     
      };
  })( jQuery );
  </code></pre>
  
  <p>Execution-</p>
  
  <pre><code>$(document).ready(function() {
  
      /* run respond and hide the main images */
      $('.z').respond(function() {
          $('.z').hide();
      });
  
  });
  </code></pre>