Fork me on GitHub

A Tip for the Use of CSS Sprites

Using CSS sprites is a great way to increase site response by lessening the number of HTTP requests needed to fetch a page.

Updating sprites can be tricky though. Browsers will cache an image containing sprites which makes adding new sprites tricky. The easiest way to get a browser to recache an image containing spites is to change the filename.

If using Drupal, to avoid having to do change the filename manually in each place a sprite is used, in a custom module you can set a Drupal variable or a PHP definition (using the define function) to designate the filename of the most latest CSS sprite.