Image URI of image instead of sprites in Ruby on Rails

dataURI-image

To whom?

  • For those on Ruby on Rails.
  • Who does not use image sprites, but is going to switch to them - and at the same time considers this to be " deadlock and gimor ."
  • Who is not going to support IE6-7 (and 8) or knows all their charms (yes it is easy to fix it - but really, let's bury them already).

Not lit

  • The spelling "data URI" vs "data URL"
  • Performance tests - yes, only theory here


Optimization of a web application (page, resource, portal - hereinafter for brevity it is simple - an application) directly depends on the number of requests to the server. Have a great presentationon this topic. As an optimization (reducing the number of requests to the server) sprites with images are used, i.e. a group of images is combined into one - and after css forces only certain parts of it are shown. This, in turn, adds a lot of effort to the developer - in the event that the developer has never used sprites, but is only going to transfer his brainchild to them. In any case, images that are placed in sprites are unlikely to ever be changed - unless, of course, you don’t redo the application design at all, i.e. Do not change the main CSS file of the application. But - why do we need a separate image file if we can use the data URI?

So the strategy


  • с необходимой фоновой картинкой вместо изображения (вместо )
    this will allow you to move all images to a css file
    with a transparent base and background image, instead of the image
    , a single-pixel transparent GIF is used for
    gluing all css into one
    fewer files - fewer requests (in RoR it is) the
    css file to the end of the md5 hash
    convenient for development - the file changes, its name changes (it is in RoR) to the
    css file in the request header: keep the year
    if the file does not change, then we store it in the cache

Also popular now: