2

Possible Duplicate:
Stopping GIF Animation Programmatically

When I have a page open with an animated GIF in it, and the tab is active in the window, it uses up CPU.

I'm wondering if there's a way to mark up the HTML so that a GIF will play for a specified amount of time or number of loops.

Or perhaps I am best served by using a static image and setting its source to the GIF on hover (which I believe most mobile browsers patch by allowing hover to be set on tap).

Community
  • 1
  • 1
Steven Lu
  • 41,389
  • 58
  • 210
  • 364

2 Answers2

1

I use Fireworks to make animated gifs and from within fireworks you can adjust those settings without having to do anything to the html.

imakeitpretty
  • 2,108
  • 5
  • 16
  • 16
  • Does a gif allow you to specify a certain number of loops before it stops? And will browsers generally follow that setting? Sure would beat the hell out of that really scary hackery being done with the `` in the other link posted. – Steven Lu Jul 17 '12 at 02:32
  • yes. I don't know what other software will do this for you, but I do it all the time with Fireworks. (if you like this answer, upvote it! Thanks!) – imakeitpretty Jul 17 '12 at 13:42
1

I don't believe HTML or the DOM provides any control over GIF animation, but you can exercise a limited amount of control from your image generation tool over the number of loops.

For example, in Photoshop:

enter image description here

IE9 and Chrome respect the loop count; I imagine that all browsers do, though I can't find a mention in the spec for how looping is supposed to behave.

GIF89a Spec

If you can't modify the images, or want to stop them at different times, perhaps just replace the animated GIF with a static GIF using a bit of JavaScript.

Tim M.
  • 53,671
  • 14
  • 120
  • 163