Search code examples
javascriptspritecss-spritesfirefox3.5

FireFox 3.5 Fetches Image Sprite Repetitively - how to prevent?


EDIT: Mozilla fixed the bug. This thread is dead.

EDIT: This is a Mozilla bug. See this thread: https://bugzilla.mozilla.org/show_bug.cgi?id=501853

I have a sprite I use for my images here: http://www.trailbehind.com/site_media/images/sprite.png

In FireFox 3.5, the sprite seems to get fetched every time I render an icon on my map, you can see the behavior in the Firebug Net Panel when you load this page and/or pan the map: http://www.trailbehind.com/node/1148091/

I had previously had similar problems to this in Internet Explorer, but I had eventually gotten this working in Safari 3/4, FF 2/3, and IE 6/7/8. Now, something is wrong in FF 3.5 :(

I tried to put this code in the of the document to prec-cache the image, but to no avail:

  var pre = new Image();
  pre.src = "/site_media/images/sprite.png"; 

Here's the code that later creates the map markers (and fetches the sprite image again). It might be GMaps related - it doesn't seem to fetch a sprite to draw each icon or otheer image on the left... just the map.

//returns an image-like GIcon based on a sprite  
function getGIconSprite(attr) {
  var myicon = new GIcon(G_DEFAULT_ICON);
  myicon.sprite = {image:"/site_media/images/sprite.png", top:0};
  myicon.iconSize = new GSize(16,16);
  myicon.iconAnchor = new GPoint(8,8);
  myicon.shadow = null;
  myicon.sprite.left = attr.offset*16;
  return myicon;
}

Solution

  • This is official FireFox 3.5 bug. Simple hack for it is to create two class for all snipped object: one common for all with background image, and the second one with background position. That's all kids!)