How could I make this simple code more efficient?
<p>I'm new to programming in general, and since I'm purely self taught, I lack some of the fundamentals of programming. This is some simple jQuery I wrote to make sure that the wrapper of a site stretches to the beginning of the footer, even if there isn't enough content:</p>

<pre><code>$(window).resize(function() {
    var footerHeight = 147;
    var windowHeight = $(window).height();
    var properHeight = windowHeight - footerHeight;
    $('#main').height(properHeight);
});
</code></pre>

<p>I define the height of the footer. Then I get the height of the viewport. Then I minus the height of the footer from the viewport. Then I apply that height to the <code>#main</code> element. I know I can use jQuery to get the height of the footer, but I had issues and it wasn't working right for some reason.</p>

<p>I have the code repeated just before, but outside of the <code>$('window').resize()</code> function, so that it runs once on on page load.</p>

<p>I feel like I could turn this into a function since it's repeated twice. Also, my main reason for asking here, is because if I resize the browser quickly for a couple seconds, my browser just eats up the CPU because of this code.</p>

<p>Apologies if this isn't the right site to ask.</p>
