1

Is there a way to only have a .gif play if it is in the screen view using JQuery or Javascript? There are so many .gif files on my page and it is causing lag (and no I cannot just remove them)

ZomoXYZ
  • 1,763
  • 21
  • 44

1 Answers1

4

You could use a plugin like https://github.com/darthrubens/gifplayer coupled with https://github.com/customd/jquery-visible

Place a static image for each gif on your website, as each element becomes visible in the viewport swap the static image for the gif and play that. As it leaves the viewport stop the gif playing and replace it with the static image again.

Burrito
  • 517
  • 3
  • 8