title: jQuery onload screen size and screen resize
body: <p>I've got some jquery that triggers some events if the window loads at size smaller than 630px or if the screen is resized to less than 620px.</p>
  
  <p>I currently have it as 2 separare if/else statements - one for onload and one for window resize - is there anyway I can merge these so I don't have duplicate the functions for each one?</p>
  
  <p>Here's my code - I've had a go but can't get it to work</p>
  
  <pre><code>$(function () {
   var $window = $(window);
   $(window).on('resize', function () {
      if ($window.width() &lt; 620) {
         $("#prd_details_smaller").append( $(".product_title"), $(".product_code"), $(".prd_reviews") );
         $("#short_desc").hide();
     }else{
         $(".col_prd_rgt").prepend( $(".product_title"), $(".product_code"), $(".prd_reviews") );
         $("#short_desc").show();    
      };
   });    
      if ($(window).width() &lt; 620) {
         $("#prd_details_smaller").append( $(".product_title"), $(".product_code"), $(".prd_reviews") );
         $("#short_desc").hide();    
      } else {
         $(".col_prd_rgt").prepend( $(".product_title"), $(".product_code"), $(".prd_reviews") );
         $("#short_desc").show();        
      }
  });
  </code></pre>