paulirish/matchMedia.js — pull request #43 by knightdr (2013-08-20 07:27:22+00:00)
Title: Rewrite of addListener to use window.resize rather than setInterval

This should provide good performance over current version because tests will only run on resize of the window. Even though this may not cover all cases, we're at least reacting to a known change in the device. Only 1 resize listener is created again for performance reasons and only for browsers that support CSS3 media queries. To do this, I save the resulting object(MediaQueryList) and its listeners to an array that get looped over on resize. This is pretty close to 100 bytes larger than the current version gzipped, so keep that in mind when reviewing. I'm not sure if there is any room for size optimization.

I'd love to hear your thoughts on this approach and see if we can do any better.