# conditioner-js

> ConditionerJS - Frizz Free, Environment-aware, JavaScript Modules

Latest version **1.2.3** (published 2016-06-23) · 0 weekly downloads

## Install

```sh
npm install conditioner-js
pnpm add conditioner-js
yarn add conditioner-js
bun add conditioner-js
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2016-06-23 |
| First published | 2015-12-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1058 |
| Author | Rik Schennink |
| Maintainers | rikschennink |
| Keywords | javascript, media queries, media query, module, responsive, context, conditions, shampoo |

## Links

- npm: https://www.npmjs.com/package/conditioner-js
- Repository: https://github.com/rikschennink/conditioner
- Homepage: http://conditionerjs.com
- Issues: https://github.com/rikschennink/conditioner/issues
- npm.io page: https://npm.io/package/conditioner-js

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.2.3 (latest) — 2016-06-23
- 1.2.2 — 2015-12-30

## README

# ConditionerJS [![Build Status](http://img.shields.io/travis/rikschennink/conditioner/master.svg)](https://travis-ci.org/rikschennink/conditioner) [![Coverage Status](http://img.shields.io/coveralls/rikschennink/conditioner/master.svg)](https://coveralls.io/r/rikschennink/conditioner?branch=master)

ConditionerJS is a JavaScript library for loading and unloading behavior based on the current user context.


## Example

Load a Google Map module only if the screen is wider than 40em and the HTML element has been seen by the user.

```html
<a href="http://maps.google.com/?ll=51.741,3.822"
   data-module="ui/Map"
   data-conditions="media:{(min-width:40em)} and element:{was visible}"> ... </a>
```

When the module has loaded ConditionerJS will automatically unload it once the conditions are no longer valid (for instance when the user resizes the viewport). 


## Documentation

The documentation and a selection of demos can be found at [conditionerjs.com](http://conditionerjs.com)


## Installation


### Package

`npm install conditioner-js`

`bower install conditioner-js`


### Manual

Add the `conditioner.js` file (found in the dist/dev folder) to your project. You'll also have to add the monitors and utilities folder. The dev version of the conditioner framework includes logging statements, the dist/min folder contains a minimized version without these statements to limit file size.



## Running tests

Run `gulp test` to spin up the test suite. 


## Requirements

Conditioner expects an AMD loader to be available. It's been tested with [RequireJS](http://requirejs.org), [Almond](https://github.com/jrburke/almond) and [Curl](https://github.com/cujojs/curl). As long as your AMD loader follows the [AMD spec](https://github.com/amdjs/amdjs-api) it should be fine.

If you're not into AMD and prefer [Browserify](http://browserify.org) that's fine too but keep in mind that your optimized file should contain all modules. If you want the best of both worlds you might be interested in [WebPack](http://webpack.github.io).

* AMD Loader / CommonJS Preprocessor
* Modern browser, IE8 is supported but requires a bit of shimming.


## Resources

* [Frizz Free JavaScript With ConditionerJS](http://www.smashingmagazine.com/2014/04/03/frizz-free-javascript-with-conditionerjs/)
* [Presenting ConditionerJS At JavaScript MVC #9](http://rikschennink.nl/thoughts/frizz-free-javascript-mvc-meetup-9/)
* [Presenting ConditionerJS At Kabisa](http://rikschennink.nl/thoughts/frizz-free-javascript-fronteers-meetup/)


## Version History

### 1.2.3

* Replaced `this` with `window` to fix Browserify root problems

### 1.2.0

* Fixed [unload handler not called](https://github.com/rikschennink/conditioner/issues/91)
* Renamed `.on` method to `addConditionMonitor` and `.is` method to `matchesCondition`
* Added `.removeConditionMonitor`
* Fixed problem where `.is`/`matchesCondition` method did not clean up Promise
* Removed global and multiline flags from quick regex test [issue 94](https://github.com/rikschennink/conditioner/issues/94)

### 1.1.0

* The `supported` property has been added which is used to determine if a module can be loaded at all
* Improved `getModule` method API
* Constructor now set when extending a module
* Performance optimisations

### 1.0.1

* Fixed [memory leaks](https://github.com/rikschennink/conditioner/issues/71)

### 1.0.0

* Bind multiple modules to the same DOM node.
* New `was` statement to make tests sticky `element:{was visible}`.
* Alternative more human readable option format `data-options=“map.zoom:10, map.type:terrain”`.
* Support for other AMD loaders, if you follow AMD specs you should be fine.
* Browserify support, for conditional loading you'll still need an AMD loader though. 
* Separate loading state attribute for binding CSS loading animations.
* Configure the paths and attributes Conditioner uses.
* `getModule` and `getModules` methods to access moduleControllers more directly.
* New `is` and `on` methods for manually testing conditions once or continually.
* `destroy` method to destroy previously initialised nodes.
* Writing your own monitors is now a lot easier.
* Fixes and small improvements.

Read the [1.0.0 closed issue list](https://github.com/rikschennink/conditioner/issues?milestone=2&page=1&state=closed) for a complete overview.


## Feedback

Always interested in your opinion, please let me know on [Twitter](http://twitter.com/rikschennink) or contact met via [hello@rikschennink.nl](mailto:hello@rikschennink.nl)


## License

[MIT](http://www.opensource.org/licenses/mit-license.php)

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