Skip to content
KuraFire edited this page Sep 1, 2011 · 60 revisions

Modernizr - a JavaScript library allowing you to use CSS3 & HTML5 while maintaining control over unsupported browsers

Filing a bug?

Please read this page before filing an issue!

Other pages

^ that has a lot of super useful links. Check it for sure.

^ things that maybe cannot be feature detected.

modernizr lite

modernizr lite gist just the basics.

Server-side implementations

Additional Tests, not in Modernizr core:

some inline plugin tests

Modernizr.addTest('orientation',function(){ 
    return 'ondeviceorientation' in window;
})


Modernizr.addTest('speechinput', function(){
    var elem = document.createElement('input'); 
    return 'speech' in elem || 'onwebkitspeechchange' in elem; 

    //  - 'webkitSpeech' in elem -> does`t work correctly in all versions of Chromium based  
    //  browsers: can return false even if they have support for speech (http://i.imgur.com/2Y40n.png)
    //  - testing with 'onwebkitspeechchange' seems to fix this problem
});


Modernizr.addTest('textshadow',function(){ 
    return document.createElement('div').style.textShadow === '';
})


Modernizr.addTest('ie8compat',function(){
    return !window.addEventListener && document.documentMode && document.documentMode == 7;
});


Modernizr.addTest('timedtrack',function(){ // subtitle support for html5 video, thx @ourmaninjapan
    return !!document.createElement('track').track;
});

// media queries test must be added into the source... (for now)
tests['mediaqueries'] = function(){ return testMediaQuery('only all'); }

var hasStrictMode = (function(){ "use strict"; return !this; })(); // via kangax


// Function.caller
supportsCaller = (function(undefined) { function test() { return test.caller !== undefined } return test() })()`

// server sent events aka eventsource
Modernizr.addTest('eventsource', function(){ return !!window.EventSource; });

more feature tests..

Sites that use it:

Modernizr is used by projects like

Clone this wiki locally