Skip to content
Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.
Branch: master
Clone or download
foolip and rejas Tweak testProps.js documentation to avoid misreading (#2426)
The lack of punctuation/capitalization made "create our own elements to
use inside of an SVG element" a plausible reading at a first pass, but
that's not the intended meaning.
Latest commit 5afbd12 Mar 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Add auto-changelog for generating a CHANGELOG.md (#2421) Feb 26, 2019
feature-detects Fix touch event detection for Chrome >= 70, see https://www.chromesta… Feb 28, 2019
lib Switch to markdown-it from remarkable (#2424) Mar 14, 2019
media fix crlf (windows) end of lines forcing to lf (unix) Oct 19, 2015
src Tweak testProps.js documentation to avoid misreading (#2426) Mar 17, 2019
test fix #1663 - Configuration Options not working (#2413) Feb 26, 2019
.coveralls.yml
.editorconfig Removing stray + Aug 2, 2014
.eslintrc Move custom ESLint rule to `no-restricted-syntax` (#2359) Aug 6, 2018
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
Gruntfile.js
LICENSE
README.md
appveyor.yml
inch.json
package-lock.json v3.7.1 Mar 14, 2019
package.json

README.md

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 on the console (in phantom):

grunt test

To run tests in the browser:

grunt browserResults

then visit http://localhost:9090/test/unit.html for unit test results

or visit http://localhost:9090/test/index.html to see which features that browser supports

To see the build tool:

  • checkout the modernizr.com 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");

Building

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

var modernizr = require("modernizr");

modernizr.build({}, 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.

License

MIT License

You can’t perform that action at this time.