0

I have a site, that only wants to run a gif twice. Is there a way to add an event listener to the gif to see if it has been looped. I'm assuming an event listener would be the best option but def open to any and all ways to implement this.

Shaina
  • 9
  • While I agree with @Brad's answer but you can check on this thread too: https://stackoverflow.com/questions/2385203/can-you-control-gif-animation-with-javascript – ArchNoob Sep 22 '17 at 19:28

1 Answers1

1

No, not if your GIF is in a normal <img> tag. There are no such events.

Ideally, you wouldn't be using GIF anyway. Use a video. Even if you need transparency, there's support for alpha channel in VP9, which you wrap in WebM. Then with <video>, you have all sorts of events for tracking playback and looping. Your videos are generally going to be much smaller in file size as well.

Brad
  • 159,648
  • 54
  • 349
  • 530