A small (540 byte-ish, gzipped+minified!), modern library for managing media queries programmatically (i.e. in JavaScript). Most media query libraries I've seen forces the developer to duplicate their media query syntaxes (from CSS file to JavaScript file). See the documentation for more information and how to use the API.
- Demo (no polyfill)
- Documentation
- Blog post explaining it
Every browser that supports window.matchMedia()
and Array Extras should be fine. Currently tested on:
mqa.js uses grunt 0.4.
$ npm install -g grunt-cli
$ cd path/to/mqa.js
$ npm install
// running separate tasks:
$ grunt jshint
$ grunt test
$ grunt requirejs
// above commands are equal to running just:
$ grunt
There's no real style-guide followed, but please follow the existing code's style. And remember to
always run grunt
before sending a pull request to make sure the unit tests and JSHint rules are passing.
When new features are being developed, unit tests and JSDoc documentation should be added as well. See existing tests and documentation for inspiration.
Dual license, MIT/GPL. Use whatever fits your project.
* = When using this polyfill, an initial event is triggered when a media query is matched when loading the document. This is not the case with native implementations and other polyfills I've tried.