Responsive imaging

This documentation explains how to add responsive images to your websites/apps. For assistance, please contact support from your Sirv account. If you don’t have a Sirv account yet, create your free account now.

Perfectly sized images

Sirv automatically delivers images to fit your users device. Whether iPhone, iPad, Android phones, tablets or desktop/laptops, Sirv will detect the available dimensions and create an image to fit.

Sirv does this by resizing the image in your Sirv account, caching the new one and rapidly delivering it to the user. Simple to setup, this is a great time-saving tool for web designers and developers.


Drag the slider to make the image progressively larger. New images will be requested by your browser and delivered by Sirv:



Responsive image demo


To use responsive imaging, follow these two steps:

1. Add class=”Sirv” to your image and use data-src instead of src, for example:

<img class="Sirv" data-src="">

2. Reference the sirv.js file, if it’s not already in your page (it’s the same file used for embedding zooms/spins):

<script src=""></script>

Lazy loading

To help pages load as fast as possible, for the best user experience, Sirv responsive images automatically use lazy loading. This loading method fetches the image when it is needed, instead of fetching all images on page load. Only images within the viewable part of the page will load. Images out of view will not load unless the user scrolls down the page and they come into view.

To use lazy loading, add a class of Sirv to an image, like so:

<img data-src="" class="Sirv" />

The loading effect smoothly fades in the image, giving a discreet, refined feeling. To alter this, you can add the img.Sirv.sirv-image-loading and img.Sirv.sirv-image-loaded classes to your page, with the settings you prefer. The default settings are:

  img.Sirv.sirv-image-loading {
    opacity: 0;
  img.Sirv.sirv-image-loaded {
    transition: opacity .4s linear;
    opacity: 1;

To remove the fade-in effect, apply this style in your HTML page:

  img.Sirv.sirv-image-loaded {
    transition: none;

To use lazy loading on an image with fixed width or height (i.e. not a responsive image), set the resize to false:

<img data-src="" class="Sirv" data-options="resize: false;" width="300" />

To disable lazy loading of your responsive images, set lazy to false:

<img data-src="" class="Sirv" data-options="lazy: false;" />

Retina images

Sirv responsive imaging supports HiDPI (retina) images, to serve beautifully sharp images to retina devices. Retina images have incredible clarity but are roughly 4 times larger in file size. For faster image downloading, you can turn off retina and Sirv will deliver 72dpi images instead.

To turn off retina images, set retina to false:

<img class="Sirv" data-src="" data-options="retina: false;">

Resize step

For better user experience, when a user resizes their browser, new images are only served if the difference in image size is at least 50px. This helps keep your page feeling fast.

The resize step can be increased to a higher value or reduced as low as 10px. To change the value, use the resizeStep option:

<img class="Sirv" data-src="" data-options="resizeStep: 100;">


Table of options that can be applied via the ‘data-options’ tag:

retinatruetrue / falseLoad retina images on HiDPI screens
resizetruetrue / falseEnable responsiveness when page is resized
resizeStep50numericWidth change threshold when resizing window (pixels, minimum 10px)
lazyfalsetrue / falseEnable lazy loading of images when they come into view

Options can alternatively be applied to all images on the page by using the script tag:

  var SirvOptions = {
    image: {
      retina: false

or like this:

  var SirvOptions = {};
  SirvOptions.image = {
    retina: false

Was this article helpful?