A JavaScript library that automatically serves high-resolution image variants (e.g., @2x, @3x) to devices with retina or high-DPI displays. Current stable version is 2.1.3, released in maintenance mode. It supports multiple pixel density levels and can swap img src attributes, inline background images, or generate CSS media queries. Unlike alternatives that require build-time processing or polyfills, retina.js works client-side with zero configuration for standard image naming conventions. It integrates with Sass, Less, and Stylus for CSS background images.
npm install retinajsVerified import paths — ran on the pinned version, not inferred.
Shows how to install, import, and use retinajs to auto-swap images on retina displays.
Use `import retinajs from 'retinajs'` instead of `require('retinajs')`. The `data-at2x` attribute is replaced by `data-rjs`.Remove jQuery dependency and chain calls. Use `retinajs(selector)` directly.
Replace `data-at2x` with `data-rjs` attribute with a number (resolution cap) or a URL string.
Upgrade to v2.1.0+ or pass an explicit collection of unprocessed images.
Ensure high-res variants are uploaded before using retina.js.
Use ES6 import: `import retinajs from 'retinajs'` or configure bundler to resolve ESM.
Upload the @2x, @3x variants to the server, or adjust the data-rjs attribute to point to a valid URL.
Ensure the script is loaded before calling retinajs. Use `<script src="retinajs.js"></script>` and call after DOM ready.
Verify that the selector matches existing elements, or pass a valid NodeList or array.
No dependency data recorded yet.