I am using srcset
to display an animated GIF for users on large devices, but need to display a static JPG to users on small and medium devices.
The following code works great when I resize my browser window on a 1x screen. The issue I'm running into is when viewing the page on iPad in portrait mode (768px), the animated GIF is displaying. I get that the browser is trying to display a higher quality image, since it's a 2x resolution, but in my case, it needs to be an entirely different image.
How can this be changed to only show the GIF if the user's screen is wider than 940px?
<img src="static.jpg" sizes="(max-width: 940px)" srcset="static.jpg 940w, animated.gif 1400w" alt="">