Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,26 @@ rels.forEach(element => {
});

```

### Find Above The Fold Lazy Loaded Images

List all images that have `loading="lazy"` above the fold

```js
function findATFLazyLoadedImages() {
const lazy = document.querySelectorAll('[loading="lazy"]');
let flag = false;
lazy.forEach((tag) => {
const position = parseInt(tag.getBoundingClientRect().top);
if (position < window.innerHeight && position !== 0) {
console.log(tag, position);
flag = true;
}
});

return flag;
}

console.log(findATFLazyLoadedImages());

```