shinsenter / defer.js

🥇 A lightweight JavaScript library that helps you lazy load (almost) anything. Defer.js is dependency-free, highly efficient, and optimized for Web Vitals.
https://shinsenter.github.io/defer.js/
MIT License
278 stars 45 forks source link

Images fallback #41

Closed CharlyFrias closed 4 years ago

CharlyFrias commented 4 years ago

I can't find a way to defer an image that has a fallback of the form:

<img src="image.svg" onerror="this.src='image.png'">

So that functions in old browsers.

Now I am using:

<script> deferimg ('img [data-src], picture, video, audio') </script>

in the body, and for the images this:

<img data-src = "image.svg" onerror = "this.src = 'image.png'">

and it works fine in modern browsers but does not put "image, png" in IE8. I have not tried in other old browsers.

Can you help me.

Thanks in advance Carlos.

shinsenter commented 4 years ago

@CharlyFrias defer.js supports IE9+, so it may not work with IE8 (not tested).

You can try using other lazy-load solutions. I am sorry.