# gulp-modernizr

> Gulp wrapper for custom Modernizr builds

Latest version **5.0.3** (published 2026-02-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install gulp-modernizr
pnpm add gulp-modernizr
yarn add gulp-modernizr
bun add gulp-modernizr
```

## Health

**Score 53/100 (C)** — status: stable.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 5.0.3 |
| Published | 2026-02-04 |
| First published | 2014-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/gulp-modernizr) |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 4 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 116 |
| Author | Modernizr |
| Maintainers | rejas, patrickkettner |
| Keywords | gulpplugin, gulp, modernizr, customizr |

## Links

- npm: https://www.npmjs.com/package/gulp-modernizr
- Repository: https://github.com/Modernizr/gulp-modernizr
- Homepage: https://github.com/Modernizr/gulp-modernizr#readme
- Issues: https://github.com/Modernizr/gulp-modernizr/issues
- npm.io page: https://npm.io/package/gulp-modernizr

## Dependencies (4)

- [vinyl](https://npm.io/package/vinyl.md) ^3.0.1
- [through2](https://npm.io/package/through2.md) ^4.0.2
- [customizr](https://npm.io/package/customizr.md) ^3.0.5
- [plugin-error](https://npm.io/package/plugin-error.md) ^2.0.1

## Recent versions

- 5.0.3 (latest) — 2026-02-04
- 5.0.2 — 2025-09-09
- 5.0.1 — 2024-11-05
- 5.0.0 — 2023-08-22
- 4.0.4 — 2023-03-05
- 4.0.3 — 2022-02-15
- 4.0.2 — 2021-03-23
- 4.0.1 — 2020-07-01
- 4.0.0 — 2020-04-07
- 3.4.1 — 2020-02-17
- 3.4.0 — 2019-10-25
- 3.3.0 — 2019-07-07
- 3.2.1 — 2019-03-20
- 3.2.0 — 2019-03-06
- 3.1.0 — 2018-11-27
- … 9 more at https://npm.io/package/gulp-modernizr/versions

## README

# gulp-modernizr 

[![Build Status](https://github.com/Modernizr/gulp-modernizr/actions/workflows/testing.yml/badge.svg)](https://github.com/Modernizr/gulp-modernizr/actions/workflows/testing.yml)
[![npm version](https://badge.fury.io/js/gulp-modernizr.svg)](https://badge.fury.io/js/gulp-modernizr)

A [Gulp](https://gulpjs.com/) wrapper for [Modernizr](https://github.com/Modernizr/customizr).

*Note*: This plugin uses version 3 of Modernizr. Make sure to check the [Github repo](https://github.com/Modernizr/Modernizr/tree/master/feature-detects) for the correct feature names (example: ```Modernizr.touch``` was renamed to ```Modernizr.touchevents```).

## Usage

First, install `gulp-modernizr` as a development dependency:

```shell
npm install --save-dev gulp-modernizr
```

Then, add it to your `gulpfile.js`:

```javascript
var modernizr = require('gulp-modernizr');

gulp.task('modernizr', function() {
  return gulp.src('./js/*.js')
    .pipe(modernizr())
    .pipe(gulp.dest('build/'))
});
```

Running the plugin will search for tests in your `src` files like this one for example:

```javascript
if (!Modernizr.objectfit) { doSomethingLikeCallAPolyfill(); }
```

and in this case add the 'objectfit' test to the ouptut file.

## API

### modernizr(fileName)

#### fileName
Type: `String`

You can optionally pass a fileName to name the Modernizr file (defaults to `modernizr.js`)

```javascript
gulp.src('./js/*.js')
  .pipe(modernizr('modernizr-custom.js'));
```

### modernizr(/*fileName, */ settings)

#### settings
Type: `Object`

You can pass settings as an object. See the [customizr repository](https://github.com/Modernizr/customizr#config-file) for valid settings.

```javascript
gulp.src('./js/*.js')
  .pipe(modernizr({
    'options': ['setClasses'],
    'tests': [
      'webworkers',
      [
        'cssgrid',
        'cssgridlegacy'
      ]
    ],
    excludeTests: ['csstransforms3d']
  })
);
```

The 'settings' object can also be required from a JSON file:

modernizr-config.json:
```javascript
{
  'options': ['setClasses'],
  'tests': [
      'webworkers',
      [
          'cssgrid',
          'cssgridlegacy'
      ]
  ],
  excludeTests: ['csstransforms3d']
}
```

gulpfile.js:

```javascript
gulp.src('./js/*.js')
 .pipe(modernizr(require('./modernizr-config.json')))
```

#### Available Settings
##### See the [customizr repository](https://github.com/Modernizr/customizr#config-file) for valid settings.

#### `settings.crawl`

By default, `glup-modernizr` will not output any `Modernizr.js` if your `gulp.src` does not contain any file, 
regardless of the `tests` you may have set.

If you only want to output a `Modernizr.js` file with some `tests` you set, just pass a fake path to `gulp.src`:

```javascript
gulp.src('fake', {allowEmpty: true})
  .pipe(modernizr({
    crawl: false,
    tests: [
      'touchevents',
    ],
  })
)
```

#### `settings.quiet`
Defaults to `false`, setting it to `true` suppresses any log output from customizr

#### `settings.uglify`
Will never be passed to customizr, see the [Gulp guidelines](https://github.com/gulpjs/gulp/blob/master/docs/writing-a-plugin/guidelines.md). The option to uglify the build goes against guidelines #1 and #3. Thus, this setting has been removed from this plugin. You may use [`gulp-uglify`](https://npmjs.org/package/gulp-uglify) to achieve this functionality in Gulp:

```javascript
gulp.src('./js/*.js')
  .pipe(modernizr())
  .pipe(uglify())
  .pipe(gulp.dest("build/"));
```

## License
Copyright (c) 2026 The Modernizr team
Licensed under the MIT license.

---
_Source: https://npm.io/package/gulp-modernizr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
