JavaScript library to load different images suiting the device
##How to install for development?
You need to install NodeJS and bower to manage dependencies and run grunt tasks like tests, jshint, concat and uglify:
- Run
npm install
- Run
npm install -g bower
- Run
bower install
- Run
grunt
- Enjoy
##How can I use it?
-
Add a script tag in your html and load devicr.min.js
-
Add a javascript tag like this:
var device = new DevicrDevice(categorizr(), new ScreenDevice(window)); var selector = new DevicrImageSelector(device, new DevicrImageFinder(device)); var devicr = new Devicr(selector); $('img.devicr').each(function() { devicr.adapt(new DevicrImage(this)); });
-
Add class devicr to your html, and a source for all devices you want like:
<a class="devicr" mobile="/mobile.jpeg" tablet="/tablet.jpeg" desktop="/desktop.jpeg" retina="/retina.jpeg"></a>