Media Queries and Enquire.js

Enquire.js is a javascript library that lets you execute scripts at specific media query breakpoints. Not only does this library let you "match" breakpoints and execute code, but it also lets you run script based on "unmatching" breakpoints.

An example of using this library is below.

enquire.register('screen and (min-width: 45em)', {
    setup : function() {
        // Load in content via AJAX (just the once)
    },
    match : function() {
        // Show sidebar
    },
    unmatch : function() {
        // Hide sidebar
    }
});

Check out the website for more details, but definitely consider using this library especially when building responsive sites that must provide rich content and data to a wide variety of devices.

You can find out more information here - http://wicky.nillia.ms/enquire.js.

Til next time...