Hi, I’m using the following code to lazy load images stored in a json file.
<script>
let imgTag = "<img style=\"margin-bottom: 4vh\" src=\""
let lazyTag = "\" loading=\"lazy\" alt=\"...\" />"
let imgPath = "imgs\\aquarelle\\main\\"
fetch("aquarelle.json")
.then(response => response.json())
.then(data => {
for(let i = 2; i < data.aquarelle.length; i++){
document.querySelector("#aquarelle").innerHTML += imgTag
+ imgPath + JSON.stringify(data.aquarelle[i].imgMain).replace(/['"]+/g, '')
+ lazyTag;
}
})
</script>
I need to display the title and description (also stored in the json file) with each image, is it possible to lazy load this with each image?
Thanks for any help.