enquire.js is a lightweight, pure JavaScript library designed to programmatically respond to CSS media queries, enabling JavaScript logic to execute when media query conditions are met or unmet. It provides a clean API for registering handlers with `match`, `unmatch`, `setup`, and `destroy` callbacks, allowing developers to manage dynamic content or behavior based on responsive breakpoints. The library, currently at version 2.1.6, has no direct runtime dependencies, though it relies on the browser's native `window.matchMedia` API and would require a polyfill for environments that do not support it. Its primary differentiator was its small footprint and pure JavaScript approach without external dependencies, offering a robust solution for enhancing responsive web design beyond CSS alone. The project appears to be unmaintained, with its last significant update approximately nine years ago, indicating an abandoned status.
npm install enquire.jsVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to register a media query handler using the global `enquire` object, reacting to viewport width changes with `match` and `unmatch` callbacks.
Include a `matchMedia` polyfill, such as 'matchmedia-polyfill' or 'media-match', before loading enquire.js. Example: `<script src="path/to/matchMedia.polyfill.js"></script>`.
Ensure `enquire` is not used by other global scripts. In modern projects, consider wrapping its usage in an IIFE or scope to minimize global exposure, or migrate to a more actively maintained media query utility.
For new projects, consider modern alternatives like `window.matchMedia` directly, CSS container queries, or actively maintained libraries that provide similar functionality and better compatibility with contemporary web development practices.
Ensure `enquire.js` is loaded via a `<script>` tag before your dependent script, or if using a module bundler, ensure the import statement is correctly placed and the global `enquire` object is accessible (e.g., `import 'enquire.js'; window.enquire.register(...)`).
You need to include a `matchMedia` polyfill for older browsers. Add a script tag linking to a polyfill (e.g., `matchmedia-polyfill`) before loading `enquire.js`.
No dependency data recorded yet.