Closed wargaluk closed 8 months ago
This is the typical snippet I copied from Eleventy project to Eleventy project, and at some point it probably lost the right context. I have now changed it to use the src
with the fallback image, images are now shown under IE.
Hi!
I recently revised the code of my Eleventy-Excellent-based website and wanted to test whether it worked at all in older browsers, including Internet Explorer. I was surprised to discover that no images at all were displayed there. This appeared to be true for vanilla Eleventy Excellent as well, e.g., the Post with an image demo. I thought this was odd because the whole idea of the
<picture>
/srcset
markup is that it contains a fallback<img>
element that should serve the image in a traditional way to browsers that don't support newer features.I looked into the
imagePlaceholder
shortcode responsible for generating the image markup, and I believe I found the culprit. The generated code inserts a 1px placeholder in thesrc
attribute of the<img>
and the location of the actual image in adata-src
attribute. However, the customdata-src
does nothing on its own, and older browsers diligently display the 1px .png. As far as I can tell based on various tutorials on the web, thedata-src
thing is used only in conjunction with libraries such as vanilla-lazyload or lazysizes, which provide lazy loading functionality to browsers that lack native support. Unfortunately, yourapp.js
does not seem to have an equivalent capability. The effect is a fallback element that fails to work as a fallback, and no 'minimum viable experience' is provided.I still haven't decided how to fix it in my own code yet, but I thought this was something you might want to know (even if support for older browsers isn't a priority for the starter).
Have a happy new year!