Modernizr

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

npm version Build Status codecov Inline docs

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.

Breaking changes with v4

  • Dropped support for node versions <= 10, please upgrade to at least version 12

  • Following tests got renamed:

    • class to es6class to keep in line with the rest of the es-tests
  • Following tests got moved in subdirectories:

    • cookies, indexeddb, indexedblob, quota-management-api, userdata moved into the storage subdirectory
    • audio moved into the audio subdirectory
    • battery moved into the battery subdirectory
    • canvas, canvastext moved into the canvas subdirectory
    • customevent, eventlistener, forcetouch, hashchange, pointerevents, proximity moved into the event subdirectory
    • exiforientation moved into the image subdirectory
    • capture, fileinput, fileinputdirectory, formatattribute, input, inputnumber-l10n, inputsearchevent, inputtypes, placeholder, requestautocomplete, validation moved into the input subdirectory
    • svg moved into the svg subdirectory
    • webgl moved into the webgl subdirectory
  • Following tests got removed:

    • touchevents: discussion
    • unicode: discussion
    • templatestrings: duplicate of the es6 detect stringtemplate
    • contains: duplicate of the es6 detect es6string
    • datalistelem: A dupe of Modernizr.input.list

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

Building Modernizr

From javascript

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");

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.

From the command-line

We also provide a command line interface for building modernizr. To see all available options run:

./bin/modernizr

Or to generate everything in 'config-all.json' run this with npm:

npm start
//outputs to ./dist/modernizr-build.js

Testing Modernizr

To execute the tests using mocha-headless-chrome on the console run:

npm test

You can also run tests in your browser of choice with this command:

npm run serve-gh-pages

and navigate to these two URLs:

http://localhost:8080/test/unit.html
http://localhost:8080/test/integration.html

Integrating Modernizr with Build Tools

This section provides guidance on how to integrate Modernizr with various build tools and frameworks, making it easier to use in your projects.

1. Integrating with Webpack

To integrate Modernizr with Webpack, follow these steps:

  1. Install Modernizr:

    npm install modernizr --save
  2. Create a Modernizr Configuration File: Create a file named modernizr-config.js in your project root:

    module.exports = {
      "feature-detects": [
        "test/feature1",
        "test/feature2",
        // Add more feature detects as needed
      ]
    };
  3. Update Webpack Configuration: Modify your Webpack configuration file (e.g., webpack.config.js) to include the Modernizr plugin:

    const ModernizrWebpackPlugin = require('modernizr-webpack-plugin');
    
    module.exports = {
      // Other configurations...
      plugins: [
        new ModernizrWebpackPlugin({
          "feature-detects": [
            "test/feature1",
            "test/feature2"
          ]
        })
      ]
    };
  4. Build Your Project: Run your Webpack build process:

    npm run build

2. Integrating with Gulp

If you are using Gulp, you can integrate Modernizr as follows:

  1. Install Modernizr:

    npm install modernizr --save-dev
  2. Create a Gulp Task: In your gulpfile.js, add a task to build Modernizr:

    const gulp = require('gulp');
    const modernizr = require('modernizr');
    
    gulp.task('modernizr', function() {
      return modernizr.build({
        "feature-detects": [
          "test/feature1",
          "test/feature2"
        ]
      }).pipe(gulp.dest('dist/'));
    });
  3. Run the Gulp Task: Execute the task to generate the Modernizr build:

    gulp modernizr

3. Integrating with Parcel

For projects using Parcel, you can integrate Modernizr as follows:

  1. Install Modernizr:

    npm install modernizr --save
  2. Create a Modernizr Configuration File: Similar to the Webpack setup, create a modernizr-config.js file:

    module.exports = {
      "feature-detects": [
        "test/feature1",
        "test/feature2"
      ]
    };
  3. Update Parcel Configuration: You can use a plugin like parcel-plugin-modernizr to integrate Modernizr:

    npm install parcel-plugin-modernizr --save-dev
  4. Build Your Project: Run Parcel to build your project:

    parcel build index.html

Conclusion

Integrating Modernizr with your build tools can enhance your web applications by allowing you to detect and respond to the capabilities of the user's browser. Follow the steps above to set up Modernizr with your preferred build tool.

For more information, refer to the Modernizr documentation.

Code of Conduct

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

License

MIT License

Modernizr/Modernizr

{
"props": {
"initialPayload": {
"allShortcutsEnabled": false,
"path": "/",
"repo": {
"id": 317757,
"defaultBranch": "master",
"name": "Modernizr",
"ownerLogin": "Modernizr",
"currentUserCanPush": false,
"isFork": false,
"isEmpty": false,
"createdAt": "2009-09-25T20:13:23.000Z",
"ownerAvatar": "https://avatars.githubusercontent.com/u/131060?v=4",
"public": true,
"private": false,
"isOrgOwned": true
},
"currentUser": null,
"refInfo": {
"name": "master",
"listCacheKey": "v0:1729089064.0",
"canEdit": false,
"refType": "branch",
"currentOid": "b1609a6907950017d9450b2a08c93dd19a66fcfa"
},
"tree": {
"items": [
{
"name": ".github",
"path": ".github",
"contentType": "directory"
},
{
"name": "bin",
"path": "bin",
"contentType": "directory"
},
{
"name": "feature-detects",
"path": "feature-detects",
"contentType": "directory"
},
{
"name": "legacy",
"path": "legacy",
"contentType": "directory"
},
{
"name": "lib",
"path": "lib",
"contentType": "directory"
},
{
"name": "media",
"path": "media",
"contentType": "directory"
},
{
"name": "scripts",
"path": "scripts",
"contentType": "directory"
},
{
"name": "src",
"path": "src",
"contentType": "directory"
},
{
"name": "test",
"path": "test",
"contentType": "directory"
},
{
"name": ".babelrc",
"path": ".babelrc",
"contentType": "file"
},
{
"name": ".editorconfig",
"path": ".editorconfig",
"contentType": "file"
},
{
"name": ".eslintrc",
"path": ".eslintrc",
"contentType": "file"
},
{
"name": ".gitattributes",
"path": ".gitattributes",
"contentType": "file"
},
{
"name": ".gitignore",
"path": ".gitignore",
"contentType": "file"
},
{
"name": "CHANGELOG.md",
"path": "CHANGELOG.md",
"contentType": "file"
},
{
"name": "HOW_TO_WRITE_FEATURE_DETECTS.md",
"path": "HOW_TO_WRITE_FEATURE_DETECTS.md",
"contentType": "file"
},
{
"name": "LICENSE",
"path": "LICENSE",
"contentType": "file"
},
{
"name": "README.hi.md",
"path": "README.hi.md",
"contentType": "file"
},
{
"name": "README.id.md",
"path": "README.id.md",
"contentType": "file"
},
{
"name": "README.ka.md",
"path": "README.ka.md",
"contentType": "file"
},
{
"name": "README.md",
"path": "README.md",
"contentType": "file"
},
{
"name": "README.pt_br.md",
"path": "README.pt_br.md",
"contentType": "file"
},
{
"name": "README.sp.md",
"path": "README.sp.md",
"contentType": "file"
},
{
"name": "README.sv.md",
"path": "README.sv.md",
"contentType": "file"
},
{
"name": "README.ta.md",
"path": "README.ta.md",
"contentType": "file"
},
{
"name": "README.tr.md",
"path": "README.tr.md",
"contentType": "file"
},
{
"name": "gulpfile.babel.js",
"path": "gulpfile.babel.js",
"contentType": "file"
},
{
"name": "inch.json",
"path": "inch.json",
"contentType": "file"
},
{
"name": "package-lock.json",
"path": "package-lock.json",
"contentType": "file"
},
{
"name": "package.json",
"path": "package.json",
"contentType": "file"
}
],
"templateDirectorySuggestionUrl": null,
"readme": null,
"totalCount": 30,
"showBranchInfobar": false
},
"fileTree": null,
"fileTreeProcessingTime": null,
"foldersToFetch": [],
"treeExpanded": false,
"symbolsExpanded": false,
"isOverview": true,
"overview": {
"banners": {
"shouldRecommendReadme": false,
"isPersonalRepo": false,
"showUseActionBanner": false,
"actionSlug": null,
"actionId": null,
"showProtectBranchBanner": false,
"publishBannersInfo": {
"dismissActionNoticePath": "/settings/dismiss-notice/publish_action_from_repo",
"releasePath": "/Modernizr/Modernizr/releases/new?marketplace=true",
"showPublishActionBanner": false
},
"interactionLimitBanner": null,
"showInvitationBanner": false,
"inviterName": null,
"actionsMigrationBannerInfo": {
"releaseTags": [],
"showImmutableActionsMigrationBanner": false,
"initialMigrationStatus": null
}
},
"codeButton": {
"contactPath": "/contact",
"isEnterprise": false,
"local": {
"protocolInfo": {
"httpAvailable": true,
"sshAvailable": null,
"httpUrl": "https://github.com/Modernizr/Modernizr.git",
"showCloneWarning": null,
"sshUrl": null,
"sshCertificatesRequired": null,
"sshCertificatesAvailable": null,
"ghCliUrl": "gh repo clone Modernizr/Modernizr",
"defaultProtocol": "http",
"newSshKeyUrl": "/settings/ssh/new",
"setProtocolPath": "/users/set_protocol"
},
"platformInfo": {
"cloneUrl": "https://desktop.github.com",
"showVisualStudioCloneButton": false,
"visualStudioCloneUrl": "https://windows.github.com",
"showXcodeCloneButton": false,
"xcodeCloneUrl": "xcode://clone?repo=https%3A%2F%2Fgithub.com%2FModernizr%2FModernizr",
"zipballUrl": "/Modernizr/Modernizr/archive/refs/heads/master.zip"
}
},
"newCodespacePath": "/codespaces/new?hide_repo_select=true&repo=317757"
},
"popovers": {
"rename": null,
"renamedParentRepo": null
},
"commitCount": "2,625",
"overviewFiles": [
{
"displayName": "README.md",
"repoName": "Modernizr",
"refName": "master",
"path": "README.md",
"preferredFileType": "readme",
"tabName": "README",
"richText": "<article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><p align=\"center\" dir=\"auto\">\n <a href=\"https://www.npmjs.com/package/modernizr\" rel=\"nofollow\"><img alt=\"Modernizr\" src=\"/Modernizr/Modernizr/raw/master/media/Modernizr-2-Logo-vertical-medium.png\" width=\"250\" style=\"max-width: 100%;\"></a>\n</p>\n<div align=\"center\" dir=\"auto\">\n<div class=\"markdown-heading\" dir=\"auto\"><h5 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.</h5><a id=\"user-content-modernizr-is-a-javascript-library-that-detects-html5-and-css3-features-in-the-users-browser\" class=\"anchor\" aria-label=\"Permalink: Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.\" href=\"#modernizr-is-a-javascript-library-that-detects-html5-and-css3-features-in-the-users-browser\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\"><a href=\"https://badge.fury.io/js/modernizr\" rel=\"nofollow\"><img src=\"https://camo.githubusercontent.com/a60bc9911f57a6c0ef6df5ac047c0bf5051edd7fee8a007efc45e1de2ae8c104/68747470733a2f2f62616467652e667572792e696f2f6a732f6d6f6465726e697a722e737667\" alt=\"npm version\" data-canonical-src=\"https://badge.fury.io/js/modernizr.svg\" style=\"max-width: 100%;\"></a>\n<a href=\"https://github.com/Modernizr/Modernizr/actions\"><img src=\"https://github.com/Modernizr/Modernizr/workflows/Testing/badge.svg\" alt=\"Build Status\" style=\"max-width: 100%;\"></a>\n<a href=\"https://codecov.io/gh/Modernizr/Modernizr\" rel=\"nofollow\"><img src=\"https://camo.githubusercontent.com/fdd6ab2a04a56bb1a7b8abc9fb49d8d309f6148a268820ff1e4771c616ac088b/68747470733a2f2f636f6465636f762e696f2f67682f4d6f6465726e697a722f4d6f6465726e697a722f6272616e63682f6d61737465722f67726170682f62616467652e737667\" alt=\"codecov\" data-canonical-src=\"https://codecov.io/gh/Modernizr/Modernizr/branch/master/graph/badge.svg\" style=\"max-width: 100%;\"></a>\n<a href=\"https://inch-ci.org/github/Modernizr/Modernizr\" rel=\"nofollow\"><img src=\"https://camo.githubusercontent.com/abc47d55d0168def5fcf333bbd0856418d01a3ed16172998770434186d667c6a/68747470733a2f2f696e63682d63692e6f72672f6769746875622f4d6f6465726e697a722f4d6f6465726e697a722e7376673f6272616e63683d6d6173746572\" alt=\"Inline docs\" data-canonical-src=\"https://inch-ci.org/github/Modernizr/Modernizr.svg?branch=master\" style=\"max-width: 100%;\"></a></p>\n</div>\n<ul dir=\"auto\">\n<li>\n<p dir=\"auto\">Read this file in Portuguese-BR <a href=\"/Modernizr/Modernizr/blob/master/README.pt_br.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Read this file in Indonesian <a href=\"/Modernizr/Modernizr/blob/master/README.id.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Read this file in Spanish <a href=\"/Modernizr/Modernizr/blob/master/README.sp.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Read this file in Swedish <a href=\"/Modernizr/Modernizr/blob/master/README.sv.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Read this file in Tamil <a href=\"/Modernizr/Modernizr/blob/master/README.ta.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Read this file in Kannada <a href=\"/Modernizr/Modernizr/blob/master/README.ka.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Read this file in Hindi <a href=\"/Modernizr/Modernizr/blob/master/README.hi.md\">here</a></p>\n</li>\n<li>\n<p dir=\"auto\">Our Website is outdated and broken, please DO NOT use it (<a href=\"https://modernizr.com\" rel=\"nofollow\">https://modernizr.com</a>) but rather build your modernizr version from npm.</p>\n</li>\n<li>\n<p dir=\"auto\"><a href=\"https://modernizr.com/docs/\" rel=\"nofollow\">Documentation</a></p>\n</li>\n<li>\n<p dir=\"auto\"><a href=\"https://modernizr.github.io/Modernizr/test/integration.html\" rel=\"nofollow\">Integration tests</a></p>\n</li>\n<li>\n<p dir=\"auto\"><a href=\"https://modernizr.github.io/Modernizr/test/unit.html\" rel=\"nofollow\">Unit tests</a></p>\n</li>\n</ul>\n<p dir=\"auto\">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 <code>Modernizr</code> object, and as classes on the <code>&lt;html&gt;</code> element. This information allows you to progressively enhance your pages with a granular level of control over the experience.</p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Breaking changes with v4</h2><a id=\"user-content-breaking-changes-with-v4\" class=\"anchor\" aria-label=\"Permalink: Breaking changes with v4\" href=\"#breaking-changes-with-v4\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<ul dir=\"auto\">\n<li>\n<p dir=\"auto\">Dropped support for node versions &lt;= 10, please upgrade to at least version 12</p>\n</li>\n<li>\n<p dir=\"auto\">Following tests got renamed:</p>\n<ul dir=\"auto\">\n<li><code>class</code> to <code>es6class</code> to keep in line with the rest of the es-tests</li>\n</ul>\n</li>\n<li>\n<p dir=\"auto\">Following tests got moved in subdirectories:</p>\n<ul dir=\"auto\">\n<li><code>cookies</code>, <code>indexeddb</code>, <code>indexedblob</code>, <code>quota-management-api</code>, <code>userdata</code> moved into the storage subdirectory</li>\n<li><code>audio</code> moved into the audio subdirectory</li>\n<li><code>battery</code> moved into the battery subdirectory</li>\n<li><code>canvas</code>, <code>canvastext</code> moved into the canvas subdirectory</li>\n<li><code>customevent</code>, <code>eventlistener</code>, <code>forcetouch</code>, <code>hashchange</code>, <code>pointerevents</code>, <code>proximity</code> moved into the event subdirectory</li>\n<li><code>exiforientation</code> moved into the image subdirectory</li>\n<li><code>capture</code>, <code>fileinput</code>, <code>fileinputdirectory</code>, <code>formatattribute</code>, <code>input</code>, <code>inputnumber-l10n</code>, <code>inputsearchevent</code>, <code>inputtypes</code>, <code>placeholder</code>, <code>requestautocomplete</code>, <code>validation</code> moved into the input subdirectory</li>\n<li><code>svg</code> moved into the svg subdirectory</li>\n<li><code>webgl</code> moved into the webgl subdirectory</li>\n</ul>\n</li>\n<li>\n<p dir=\"auto\">Following tests got removed:</p>\n<ul dir=\"auto\">\n<li><code>touchevents</code>: <a href=\"https://github.com/Modernizr/Modernizr/pull/2432\" data-hovercard-type=\"pull_request\" data-hovercard-url=\"/Modernizr/Modernizr/pull/2432/hovercard\">discussion</a></li>\n<li><code>unicode</code>: <a href=\"https://github.com/Modernizr/Modernizr/issues/2468\" data-hovercard-type=\"issue\" data-hovercard-url=\"/Modernizr/Modernizr/issues/2468/hovercard\">discussion</a></li>\n<li><code>templatestrings</code>: duplicate of the es6 detect <code>stringtemplate</code></li>\n<li><code>contains</code>: duplicate of the es6 detect <code>es6string</code></li>\n<li><code>datalistelem</code>: A dupe of Modernizr.input.list</li>\n</ul>\n</li>\n</ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">New Asynchronous Event Listeners</h2><a id=\"user-content-new-asynchronous-event-listeners\" class=\"anchor\" aria-label=\"Permalink: New Asynchronous Event Listeners\" href=\"#new-asynchronous-event-listeners\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">Often times people want to know when an asynchronous test is done so they can allow their application to react to it.\nIn the past, you've had to rely on watching properties or <code>&lt;html&gt;</code> classes. Only events on <strong>asynchronous</strong> tests are\nsupported. Synchronous tests should be handled synchronously to improve speed and to maintain consistency.</p>\n<p dir=\"auto\">The new API looks like this:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"// Listen to a test, give it a callback\nModernizr.on(&quot;testname&quot;, function (result) {\n if (result) {\n console.log(&quot;The test passed!&quot;);\n } else {\n console.log(&quot;The test failed!&quot;);\n }\n});\"><pre><span class=\"pl-c\">// Listen to a test, give it a callback</span>\n<span class=\"pl-v\">Modernizr</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">on</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">\"testname\"</span><span class=\"pl-kos\">,</span> <span class=\"pl-k\">function</span> <span class=\"pl-kos\">(</span><span class=\"pl-s1\">result</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-k\">if</span> <span class=\"pl-kos\">(</span><span class=\"pl-s1\">result</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">log</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">\"The test passed!\"</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span> <span class=\"pl-k\">else</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">log</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">\"The test failed!\"</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n <span class=\"pl-kos\">}</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span></pre></div>\n<p dir=\"auto\">We guarantee that we'll only invoke your function once (per time that you call <code>on</code>). We are currently not exposing\na method for exposing the <code>trigger</code> functionality. Instead, if you'd like to have control over async tests, use the\n<code>src/addTest</code> feature, and any test that you set will automatically expose and trigger the <code>on</code> functionality.</p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Getting Started</h2><a id=\"user-content-getting-started\" class=\"anchor\" aria-label=\"Permalink: Getting Started\" href=\"#getting-started\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<ul dir=\"auto\">\n<li>Clone or download the repository</li>\n<li>Install project dependencies with <code>npm install</code></li>\n</ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Building Modernizr</h2><a id=\"user-content-building-modernizr\" class=\"anchor\" aria-label=\"Permalink: Building Modernizr\" href=\"#building-modernizr\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">From javascript</h3><a id=\"user-content-from-javascript\" class=\"anchor\" aria-label=\"Permalink: From javascript\" href=\"#from-javascript\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">Modernizr can be used programmatically via npm:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"var modernizr = require(&quot;modernizr&quot;);\"><pre><span class=\"pl-k\">var</span> <span class=\"pl-s1\">modernizr</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">\"modernizr\"</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span></pre></div>\n<p dir=\"auto\">A <code>build</code> method is exposed for generating custom Modernizr builds. Example:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"var modernizr = require(&quot;modernizr&quot;);\n\nmodernizr.build({}, function (result) {\n console.log(result); // the build\n});\"><pre><span class=\"pl-k\">var</span> <span class=\"pl-s1\">modernizr</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">\"modernizr\"</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">modernizr</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">build</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span><span class=\"pl-kos\">}</span><span class=\"pl-kos\">,</span> <span class=\"pl-k\">function</span> <span class=\"pl-kos\">(</span><span class=\"pl-s1\">result</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-smi\">console</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">log</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">result</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span> <span class=\"pl-c\">// the build</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span></pre></div>\n<p dir=\"auto\">The first parameter takes a JSON object of options and feature-detects to include. See <a href=\"/Modernizr/Modernizr/blob/master/lib/config-all.json\"><code>lib/config-all.json</code></a> for all available options.</p>\n<p dir=\"auto\">The second parameter is a function invoked on task completion.</p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">From the command-line</h3><a id=\"user-content-from-the-command-line\" class=\"anchor\" aria-label=\"Permalink: From the command-line\" href=\"#from-the-command-line\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">We also provide a command line interface for building modernizr.\nTo see all available options run:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"./bin/modernizr\"><pre>./bin/modernizr</pre></div>\n<p dir=\"auto\">Or to generate everything in 'config-all.json' run this with npm:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm start\n//outputs to ./dist/modernizr-build.js\"><pre>npm start\n//outputs to ./dist/modernizr-build.js</pre></div>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Testing Modernizr</h2><a id=\"user-content-testing-modernizr\" class=\"anchor\" aria-label=\"Permalink: Testing Modernizr\" href=\"#testing-modernizr\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">To execute the tests using mocha-headless-chrome on the console run:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm test\"><pre>npm <span class=\"pl-c1\">test</span></pre></div>\n<p dir=\"auto\">You can also run tests in your browser of choice with this command:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm run serve-gh-pages\"><pre>npm run serve-gh-pages</pre></div>\n<p dir=\"auto\">and navigate to these two URLs:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"http://localhost:8080/test/unit.html\nhttp://localhost:8080/test/integration.html\"><pre>http://localhost:8080/test/unit.html\nhttp://localhost:8080/test/integration.html</pre></div>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Integrating Modernizr with Build Tools</h2><a id=\"user-content-integrating-modernizr-with-build-tools\" class=\"anchor\" aria-label=\"Permalink: Integrating Modernizr with Build Tools\" href=\"#integrating-modernizr-with-build-tools\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">This section provides guidance on how to integrate Modernizr with various build tools and frameworks, making it easier to use in your projects.</p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">1. Integrating with Webpack</h3><a id=\"user-content-1-integrating-with-webpack\" class=\"anchor\" aria-label=\"Permalink: 1. Integrating with Webpack\" href=\"#1-integrating-with-webpack\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">To integrate Modernizr with Webpack, follow these steps:</p>\n<ol dir=\"auto\">\n<li>\n<p dir=\"auto\"><strong>Install Modernizr</strong>:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm install modernizr --save\"><pre>npm install modernizr --save</pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Create a Modernizr Configuration File</strong>:\nCreate a file named <code>modernizr-config.js</code> in your project root:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"module.exports = {\n &quot;feature-detects&quot;: [\n &quot;test/feature1&quot;,\n &quot;test/feature2&quot;,\n // Add more feature detects as needed\n ]\n};\"><pre><span class=\"pl-smi\">module</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">exports</span> <span class=\"pl-c1\">=</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-s\">\"feature-detects\"</span>: <span class=\"pl-kos\">[</span>\n <span class=\"pl-s\">\"test/feature1\"</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-s\">\"test/feature2\"</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-c\">// Add more feature detects as needed</span>\n <span class=\"pl-kos\">]</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">;</span></pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Update Webpack Configuration</strong>:\nModify your Webpack configuration file (e.g., <code>webpack.config.js</code>) to include the Modernizr plugin:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const ModernizrWebpackPlugin = require('modernizr-webpack-plugin');\n\nmodule.exports = {\n // Other configurations...\n plugins: [\n new ModernizrWebpackPlugin({\n &quot;feature-detects&quot;: [\n &quot;test/feature1&quot;,\n &quot;test/feature2&quot;\n ]\n })\n ]\n};\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-v\">ModernizrWebpackPlugin</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'modernizr-webpack-plugin'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-smi\">module</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">exports</span> <span class=\"pl-c1\">=</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-c\">// Other configurations...</span>\n <span class=\"pl-c1\">plugins</span>: <span class=\"pl-kos\">[</span>\n <span class=\"pl-k\">new</span> <span class=\"pl-v\">ModernizrWebpackPlugin</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-s\">\"feature-detects\"</span>: <span class=\"pl-kos\">[</span>\n <span class=\"pl-s\">\"test/feature1\"</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-s\">\"test/feature2\"</span>\n <span class=\"pl-kos\">]</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span>\n <span class=\"pl-kos\">]</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">;</span></pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Build Your Project</strong>:\nRun your Webpack build process:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm run build\"><pre>npm run build</pre></div>\n</li>\n</ol>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">2. Integrating with Gulp</h3><a id=\"user-content-2-integrating-with-gulp\" class=\"anchor\" aria-label=\"Permalink: 2. Integrating with Gulp\" href=\"#2-integrating-with-gulp\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">If you are using Gulp, you can integrate Modernizr as follows:</p>\n<ol dir=\"auto\">\n<li>\n<p dir=\"auto\"><strong>Install Modernizr</strong>:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm install modernizr --save-dev\"><pre>npm install modernizr --save-dev</pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Create a Gulp Task</strong>:\nIn your <code>gulpfile.js</code>, add a task to build Modernizr:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"const gulp = require('gulp');\nconst modernizr = require('modernizr');\n\ngulp.task('modernizr', function() {\n return modernizr.build({\n &quot;feature-detects&quot;: [\n &quot;test/feature1&quot;,\n &quot;test/feature2&quot;\n ]\n }).pipe(gulp.dest('dist/'));\n});\"><pre><span class=\"pl-k\">const</span> <span class=\"pl-s1\">gulp</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'gulp'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n<span class=\"pl-k\">const</span> <span class=\"pl-s1\">modernizr</span> <span class=\"pl-c1\">=</span> <span class=\"pl-en\">require</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'modernizr'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n\n<span class=\"pl-s1\">gulp</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">task</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'modernizr'</span><span class=\"pl-kos\">,</span> <span class=\"pl-k\">function</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">)</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-k\">return</span> <span class=\"pl-s1\">modernizr</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">build</span><span class=\"pl-kos\">(</span><span class=\"pl-kos\">{</span>\n <span class=\"pl-s\">\"feature-detects\"</span>: <span class=\"pl-kos\">[</span>\n <span class=\"pl-s\">\"test/feature1\"</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-s\">\"test/feature2\"</span>\n <span class=\"pl-kos\">]</span>\n <span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">pipe</span><span class=\"pl-kos\">(</span><span class=\"pl-s1\">gulp</span><span class=\"pl-kos\">.</span><span class=\"pl-en\">dest</span><span class=\"pl-kos\">(</span><span class=\"pl-s\">'dist/'</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">)</span><span class=\"pl-kos\">;</span></pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Run the Gulp Task</strong>:\nExecute the task to generate the Modernizr build:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"gulp modernizr\"><pre>gulp modernizr</pre></div>\n</li>\n</ol>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">3. Integrating with Parcel</h3><a id=\"user-content-3-integrating-with-parcel\" class=\"anchor\" aria-label=\"Permalink: 3. Integrating with Parcel\" href=\"#3-integrating-with-parcel\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">For projects using Parcel, you can integrate Modernizr as follows:</p>\n<ol dir=\"auto\">\n<li>\n<p dir=\"auto\"><strong>Install Modernizr</strong>:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm install modernizr --save\"><pre>npm install modernizr --save</pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Create a Modernizr Configuration File</strong>:\nSimilar to the Webpack setup, create a <code>modernizr-config.js</code> file:</p>\n<div class=\"highlight highlight-source-js notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"module.exports = {\n &quot;feature-detects&quot;: [\n &quot;test/feature1&quot;,\n &quot;test/feature2&quot;\n ]\n};\"><pre><span class=\"pl-smi\">module</span><span class=\"pl-kos\">.</span><span class=\"pl-c1\">exports</span> <span class=\"pl-c1\">=</span> <span class=\"pl-kos\">{</span>\n <span class=\"pl-s\">\"feature-detects\"</span>: <span class=\"pl-kos\">[</span>\n <span class=\"pl-s\">\"test/feature1\"</span><span class=\"pl-kos\">,</span>\n <span class=\"pl-s\">\"test/feature2\"</span>\n <span class=\"pl-kos\">]</span>\n<span class=\"pl-kos\">}</span><span class=\"pl-kos\">;</span></pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Update Parcel Configuration</strong>:\nYou can use a plugin like <code>parcel-plugin-modernizr</code> to integrate Modernizr:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"npm install parcel-plugin-modernizr --save-dev\"><pre>npm install parcel-plugin-modernizr --save-dev</pre></div>\n</li>\n<li>\n<p dir=\"auto\"><strong>Build Your Project</strong>:\nRun Parcel to build your project:</p>\n<div class=\"highlight highlight-source-shell notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"parcel build index.html\"><pre>parcel build index.html</pre></div>\n</li>\n</ol>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Conclusion</h3><a id=\"user-content-conclusion\" class=\"anchor\" aria-label=\"Permalink: Conclusion\" href=\"#conclusion\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">Integrating Modernizr with your build tools can enhance your web applications by allowing you to detect and respond to the capabilities of the user's browser. Follow the steps above to set up Modernizr with your preferred build tool.</p>\n<p dir=\"auto\">For more information, refer to the <a href=\"https://modernizr.com/docs/\" rel=\"nofollow\">Modernizr documentation</a>.</p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">Code of Conduct</h2><a id=\"user-content-code-of-conduct\" class=\"anchor\" aria-label=\"Permalink: Code of Conduct\" href=\"#code-of-conduct\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\">This project adheres to the <a href=\"https://github.com/Modernizr/Modernizr/blob/master/.github/CODE_OF_CONDUCT.md\">Open Code of Conduct</a>.\nBy participating, you are expected to honor this code.</p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 tabindex=\"-1\" class=\"heading-element\" dir=\"auto\">License</h2><a id=\"user-content-license\" class=\"anchor\" aria-label=\"Permalink: License\" href=\"#license\"><svg class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"></path></svg></a></div>\n<p dir=\"auto\"><a href=\"https://opensource.org/licenses/MIT\" rel=\"nofollow\">MIT License</a></p>\n</article>",
"loaded": true,
"timedOut": false,
"errorMessage": null,
"headerInfo": {
"toc": [
{
"level": 5,
"text": "Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.",
"anchor": "modernizr-is-a-javascript-library-that-detects-html5-and-css3-features-in-the-users-browser",
"htmlText": "Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser."
},
{
"level": 2,
"text": "Breaking changes with v4",
"anchor": "breaking-changes-with-v4",
"htmlText": "Breaking changes with v4"
},
{
"level": 2,
"text": "New Asynchronous Event Listeners",
"anchor": "new-asynchronous-event-listeners",
"htmlText": "New Asynchronous Event Listeners"
},
{
"level": 2,
"text": "Getting Started",
"anchor": "getting-started",
"htmlText": "Getting Started"
},
{
"level": 2,
"text": "Building Modernizr",
"anchor": "building-modernizr",
"htmlText": "Building Modernizr"
},
{
"level": 3,
"text": "From javascript",
"anchor": "from-javascript",
"htmlText": "From javascript"
},
{
"level": 3,
"text": "From the command-line",
"anchor": "from-the-command-line",
"htmlText": "From the command-line"
},
{
"level": 2,
"text": "Testing Modernizr",
"anchor": "testing-modernizr",
"htmlText": "Testing Modernizr"
},
{
"level": 2,
"text": "Integrating Modernizr with Build Tools",
"anchor": "integrating-modernizr-with-build-tools",
"htmlText": "Integrating Modernizr with Build Tools"
},
{
"level": 3,
"text": "1. Integrating with Webpack",
"anchor": "1-integrating-with-webpack",
"htmlText": "1. Integrating with Webpack"
},
{
"level": 3,
"text": "2. Integrating with Gulp",
"anchor": "2-integrating-with-gulp",
"htmlText": "2. Integrating with Gulp"
},
{
"level": 3,
"text": "3. Integrating with Parcel",
"anchor": "3-integrating-with-parcel",
"htmlText": "3. Integrating with Parcel"
},
{
"level": 3,
"text": "Conclusion",
"anchor": "conclusion",
"htmlText": "Conclusion"
},
{
"level": 2,
"text": "Code of Conduct",
"anchor": "code-of-conduct",
"htmlText": "Code of Conduct"
},
{
"level": 2,
"text": "License",
"anchor": "license",
"htmlText": "License"
}
],
"siteNavLoginPath": "/login?return_to=https%3A%2F%2Fgithub.com%2FModernizr%2FModernizr"
}
},
{
"displayName": "CODE_OF_CONDUCT.md",
"repoName": "Modernizr",
"refName": "master",
"path": ".github/CODE_OF_CONDUCT.md",
"preferredFileType": "code_of_conduct",
"tabName": "Code of conduct",
"richText": null,
"loaded": false,
"timedOut": false,
"errorMessage": null,
"headerInfo": {
"toc": null,
"siteNavLoginPath": "/login?return_to=https%3A%2F%2Fgithub.com%2FModernizr%2FModernizr"
}
},
{
"displayName": "LICENSE",
"repoName": "Modernizr",
"refName": "master",
"path": "LICENSE",
"preferredFileType": "license",
"tabName": "MIT",
"richText": null,
"loaded": false,
"timedOut": false,
"errorMessage": null,
"headerInfo": {
"toc": null,
"siteNavLoginPath": "/login?return_to=https%3A%2F%2Fgithub.com%2FModernizr%2FModernizr"
}
}
],
"overviewFilesProcessingTime": 0
}
},
"appPayload": {
"helpUrl": "https://docs.github.com",
"findFileWorkerPath": "/assets-cdn/worker/find-file-worker-9f8a877aa99f.js",
"findInFileWorkerPath": "/assets-cdn/worker/find-in-file-worker-eb3d353f90ce.js",
"githubDevUrl": null,
"enabled_features": {
"code_nav_ui_events": false,
"overview_shared_code_dropdown_button": false,
"react_blob_overlay": false,
"copilot_conversational_ux_embedding_update": false,
"copilot_smell_icebreaker_ux": true,
"copilot_workspace": false,
"accessible_code_button": true,
"github_models_prompt_link": false
}
}
}
}
{
"accept-ranges": "bytes",
"cache-control": "max-age=0, private, must-revalidate",
"content-encoding": "gzip",
"content-security-policy": "default-src 'none'; base-uri 'self'; child-src github.com/assets-cdn/worker/ github.com/webpack/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.com/assets-cdn/worker/ github.com/webpack/ github.com/assets/ gist.github.com/assets-cdn/worker/",
"content-type": "text/html; charset=utf-8",
"date": "Sun, 08 Dec 2024 22:05:01 GMT",
"etag": "e78b723b2762b419d0eb56269fd21ad6",
"referrer-policy": "no-referrer-when-downgrade",
"server": "GitHub.com",
"set-cookie": "logged_in=no; Path=/; Domain=github.com; Expires=Mon, 08 Dec 2025 22:05:01 GMT; HttpOnly; Secure; SameSite=Lax",
"strict-transport-security": "max-age=31536000; includeSubdomains; preload",
"transfer-encoding": "chunked",
"vary": "X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, Accept-Encoding, Accept, X-Requested-With",
"x-content-type-options": "nosniff",
"x-frame-options": "deny",
"x-github-request-id": "85F6:242837:173AFBA:1E13533:6756180D",
"x-xss-protection": "0"
}