I embedded an animated gif into my CSS code like this:
.magicBg {
background-image: url(data:image/gif;base64,R0lGODlhAQBkAPcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0ND ...
}
This animated gif is set to play only once.
However, after the gif plays once as the background of an element, it does not replay. Using
$('body').removeClass( 'magicBg' );
$('body').addClass( 'magicBg' )
does not work — the gif resumes from the final frame. How can I make it restart from the beginning each time the class is added?
I checked another answer that suggests reloading the gif with random URL parameters from the server. Unfortunately, this won't work for me as the image is encoded in the CSS. Is there a way to add a random date stamp to the base64 data?