Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
Pull request Compare This branch is 53 commits behind Modernizr:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin allow for setClasses to be included via cli flag (#2043) Jul 31, 2016
feature-detects Remove hand.js polyfill, expand notes/description for Pointer Events (#… Jun 12, 2017
lib Remove hand.js polyfill, expand notes/description for Pointer Events (#… Jun 12, 2017
media fix crlf (windows) end of lines forcing to lf (unix) Oct 19, 2015
src Fix minor typos in comment block Nov 22, 2016
test remove stale jshint control comments Aug 7, 2016
.coveralls.yml updates and saucelabs desktop support Apr 18, 2015
.editorconfig Removing stray + Aug 2, 2014
.eslintrc Fix "elem.parentNode is null" with Flashblock (#2063) Sep 2, 2016
.gitignore dont cause the cli test to create a file that I keep accidentally adding Jan 18, 2016
.jshintignore Create .jshintrc file, update jshint grunt task Mar 12, 2014
.npmignore Don't include dotfiles in npm package Apr 6, 2015
.travis.yml chore: drop support for Node.js 0.10 Oct 31, 2016
Gruntfile.js block direct usage of getComputedStyle, as it causes problems in cert… Jul 31, 2016
LICENSE Add bang so minification is easier Jan 7, 2015
appveyor.yml Fetch automation script via `npm` Sep 18, 2015
package.json v3.5.0 Apr 13, 2017 chore(readme): fix missing COC link (#2211) Jun 7, 2017

Modernizr Build Status Inline docs

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

Modernizr tests which native CSS3 and HTML5 features are available in the current UA and makes the results available to you in two ways: as properties on a global Modernizr object, and as classes on the <html> element. This information allows you to progressively enhance your pages with a granular level of control over the experience.

This project adheres to the Open Code of Conduct. By participating, you are expected to honor this code.

New Asynchronous Event Listeners

Often times people want to know when an asynchronous test is done so they can allow their application to react to it. In the past, you've had to rely on watching properties or <html> classes. Only events on asynchronous tests are supported. Synchronous tests should be handled synchronously to improve speed and to maintain consistency.

The new API looks like this:

// Listen to a test, give it a callback
Modernizr.on('testname', function( result ) {
  if (result) {
    console.log('The test passed!');
  else {
    console.log('The test failed!');

We guarantee that we'll only invoke your function once (per time that you call on). We are currently not exposing a method for exposing the trigger functionality. Instead, if you'd like to have control over async tests, use the src/addTest feature, and any test that you set will automatically expose and trigger the on functionality.

Getting Started

  • Clone or download the repository
  • Install project dependencies with npm install

Test suite

Run the test suite

Building Modernizr v3

To generate everything in 'config-all.json':

npm install
./bin/modernizr -c lib/config-all.json
//outputs to ./modernizr.js

To run tests (in phantom):

grunt test

To run tests (in browser):

grunt build
serve .
visit <url>/test

To see simple build in browser:

serve the root dir, <url>/test/modular.html

To see the build tool:

  • checkout the code
  • install all your gems and bundles and jekyll
  • jekyll
  • serve ./_sites
  • visit /download
  • It should be just a big list of things you can build with no frills.

API Reference

Modernizr can be used programmatically via npm:

var modernizr = require("modernizr");


A build method is exposed for generating custom Modernizr builds. Example:

var modernizr = require("modernizr");{}, function (result) {
  console.log(result); // the build

The first parameter takes a JSON object of options and feature-detects to include. See lib/config-all.json for all available options.

The second parameter is a function invoked on task completion.


MIT License