I've been experimenting with lazy loading background images, starting with a low resolution image that is then replaced with a high resolution one. I've tested various lazy loaders, but they all seem to exhibit the same issue - a flicker when the image switches. I tried using Yall Lazy Image Loader and made some tweaks so that the image is loaded before being applied to the background, but there's still a brief white flicker as the image changes. This flicker is more noticeable in Firefox, especially when the image isn't cached.
Any suggestions? Here's the codepen link:
https://codepen.io/kehza/pen/PoPKZBa
newImg.onload = function () {
this.backgroundTarget.classList.remove(lazyBackgroundClass);
this.parentNode.removeChild(this);
};
Appreciate any help!