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:

```
$(window).resize(function() {
    var footerHeight = 147;
    var windowHeight = $(window).height();
    var properHeight = windowHeight - footerHeight;
    $('#main').height(properHeight);
});

```

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 `#main` 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.

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

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.

Apologies if this isn't the right site to ask.