Quick & Dirty Media Feature detection

JavaScript

var dpr = window.devicePixelRatio,
    msg = '';
// devicePixelRatio property
if (dpr) { msg += 'devicePixelRatio: ' + dpr; }
// matchMedia method
if (window.matchMedia) {
// resolution feature & dpi unit
    if (window.matchMedia('(min-resolution: 96dpi)').matches) { msg += '\ndpi: true'; }
// resolution feature & dppx unit
    if (window.matchMedia('(min-resolution: 1dppx)').matches) { msg += '\ndppx: true'; }
// -webkit-device-pixel-ratio feature
    if (window.matchMedia('(-webkit-min-device-pixel-ratio: 1)').matches) { msg += '\n-wk-dpr: true'; }
// -o-device-pixel-ratio feature
    if (window.matchMedia('(-o-min-device-pixel-ratio: 1/1)').matches) { msg += '\n-o-dpr: true'; }
}
window.alert(msg);