In a code editor like VS Code, search for:
(<img\b(?![^>]*\bloading\s*=))([^>]*)(>)
This finds <img>
tags missing loading="lazy"
. You can then add loading="lazy"
manually or in bulk.
To do it in bulk, toggle replace on VS Code, then paste this replace regex
$1 loading="lazy"$2$3
Explanation:
(<img\b(?![^>]*\bloading\s*=))
matches<img
only if it does not already have aloading
attribute([^>]*)
matches everything inside the tag(>)
matches the closing>
of the tag$1 loading="lazy"$2$3
insertsloading="lazy"
right after<img
, keeping all other attributes intact.