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).
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:
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.