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 the browser of your choice with this command:

npm run serve-gh-pages

and navigating to these two URLs:

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

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:1697751544.0",
"canEdit": false,
"refType": "branch",
"currentOid": "44fa7b07c367a1814e8699e3a2f15c53fbe32df7"
},
"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,
"recentlyTouchedDataChannel": null,
"publishBannersInfo": {
"dismissActionNoticePath": "/settings/dismiss-notice/publish_action_from_repo",
"releasePath": "/Modernizr/Modernizr/releases/new?marketplace=true",
"showPublishActionBanner": false
},
"interactionLimitBanner": null,
"showInvitationBanner": false,
"inviterName": 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": "https://developer.apple.com",
"zipballUrl": "/Modernizr/Modernizr/archive/refs/heads/master.zip"
}
},
"newCodespacePath": "/codespaces/new?hide_repo_select=true&repo=317757"
},
"popovers": {
"rename": null,
"renamedParentRepo": null
},
"commitCount": "2,619",
"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<h5 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-modernizr-is-a-javascript-library-that-detects-html5-and-css3-features-in-the-users-browser\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.</h5>\n<p dir=\"auto\"><a href=\"https://badge.fury.io/js/modernizr\" rel=\"nofollow\"><img src=\"https://camo.githubusercontent.com/8492a323d0f067a6b0441c7827db876792ed5787a424b8b7f3df3fd01fc7c5f7/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/371ac685baa4a92501a4b561588526a0a65574287ddfcfbbb001c42c8ef10172/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/1143524255a87bbd1b4263ec938ad618206d3d5e816871811df5dfb42ea16f96/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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-breaking-changes-with-v4\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>Breaking changes with v4</h2>\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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-new-asynchronous-event-listeners\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>New Asynchronous Event Listeners</h2>\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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-getting-started\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>Getting Started</h2>\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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-building-modernizr\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>Building Modernizr</h2>\n<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-from-javascript\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>From javascript</h3>\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<h3 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-from-the-command-line\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>From the command-line</h3>\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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-testing-modernizr\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>Testing Modernizr</h2>\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 the browser of your 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 navigating 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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-code-of-conduct\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>Code of Conduct</h2>\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<h2 tabindex=\"-1\" dir=\"auto\"><a id=\"user-content-license\" class=\"anchor\" aria-hidden=\"true\" tabindex=\"-1\" 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>License</h2>\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": "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": 23.794302
}
},
"appPayload": {
"helpUrl": "https://docs.github.com",
"findFileWorkerPath": "/assets-cdn/worker/find-file-worker-32bb159cc57c.js",
"findInFileWorkerPath": "/assets-cdn/worker/find-in-file-worker-c6704d501c10.js",
"githubDevUrl": null,
"enabled_features": {
"code_nav_ui_events": false,
"copilot_conversational_ux": false,
"copilot_conversational_ux_embedding_update": false,
"copilot_popover_file_editor_header": false,
"copilot_smell_icebreaker_ux": true,
"copilot_workspace": false,
"codeview_firefox_inert": true
}
}
}
}
{
"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/ 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 api.githubcopilot.com objects-origin.githubusercontent.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; font-src github.githubassets.com; form-action 'self' github.com gist.github.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com 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/ gist.github.com/assets-cdn/worker/",
"content-type": "text/html; charset=utf-8",
"date": "Mon, 26 Feb 2024 11:35:15 GMT",
"etag": "5102d2b3c1ce936752db2fc9a3de8c6b",
"referrer-policy": "no-referrer-when-downgrade",
"server": "GitHub.com",
"set-cookie": "logged_in=no; Path=/; Domain=github.com; Expires=Wed, 26 Feb 2025 11:35:15 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": "B4FA:2DC5:1D5D202:29976EF:65DC7773",
"x-xss-protection": "0"
}