Speeding up window resize function performance
<p>I have some script similar to the following:</p>

<pre><code>var breakpoints = [0,240,480,960,9999],
    bpCount = breakpoints.length,
    windowsize = 0;

window.onresize = function() {

    windowsize = document.body.clientWidth;

    for(var i=0; i&lt;bpCount; i++) {
        if(windowsize &gt;= breakpoints[i] &amp;&amp; windowsize &lt; breakpoints[i+1]) {
            doSomething(breakpoints[i]);
            break;
        }
    }    

};
</code></pre>

<p>However this seems to run pretty slowly, even in Chrome on a decent PC, and even when 'doSomething' is just performing a 'console.log', so I was just wondering if there was any better way of checking whether the screen size is between two values as it resizes?</p>

<p>Thanks</p>
