How to detect responsive breakpoints of Twitter Bootstrap 3 using JavaScript

Insert the following HTML elements just before </body>:

<div class="device-xs visible-xs"></div>
<div class="device-sm visible-sm"></div>
<div class="device-md visible-md"></div>
<div class="device-lg visible-lg"></div>

Then, use this javascript code to detect, for example, the smallest breakpoint:

<script>
    $(document).ready(function() {
 
        onStageResize();

        $(window).resize(function() {
            onStageResize();
        });
 
        function isBreakpoint( alias ) {
            return $('.device-' + alias).is(':visible');
        }
 
        function onStageResize() {
            if( isBreakpoint('xs') ) {
                console.log('xs');
            }
        }
 
    });
</script>