Why does my GIF not play every time it appears?

The first time my GIF appears, it plays. Subsequently, it appears, but remains static (as if played). Sometimes, when an input leading up to the GIF appearance is different, it plays again. What may cause this behavior?


Thanks!

Hi YS Yeo,

(Edit: thanks for your observation Kilian Hekhuis)

An alternative to the solution assif_tiger wrote here, you could also use an external image editing program, to change the GIF's looping settings. 

For example in Photoshop open the gif, go to the Window tab and select timeline, set option "Forever".

I hope this helps, regards!


@Marco: I think the OP means an animated GIF not playing, not that it repeats across the page ;)

YS Yeo wrote:

The first time my GIF appears, it plays. Subsequently, it appears, but remains static (as if played). Sometimes, when an input leading up to the GIF appearance is different, it plays again. What may cause this behavior?


Thanks!

Hi,

you can also add a ?+Math.random() to the end of the picture src and it'll reload the .gif.

img.src = "your_image_url.gif"+"?a="+Math.random();

Thanks! Where do I put +"?a="+Math.random()?

Here?: