No empty src or href attributes
Why it matters
An <img src=""> or <a href=""> is not a no-op — browsers resolve the empty string against the current document's URL and fire a second request for the page itself. That doubles server load on every page view, pollutes analytics with phantom pageviews, breaks Lighthouse audits, and in image contexts renders a broken-image placeholder users see. It's an AI-authored bug pattern: a conditional branch that forgot to drop the attribute when the value is missing.
Severity rationale
Medium because empty attributes waste bandwidth, trigger self-referential page loads, and visibly break image and link rendering.
Remediation
Either omit the attribute entirely when the value is missing, or gate the element itself. In JSX, use conditional rendering rather than always emitting the attribute:
// wrong — emits src="" when imageUrl is falsy
<img src={imageUrl} alt={alt} />
// right — omit the element, or provide a fallback
{imageUrl ? <img src={imageUrl} alt={alt} /> : null}
Audit your templates with grep -rn 'src=""\|href=""' src/ public/.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Site Health Check audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
Taxons
History
- 2026-04-18·v1.0.0·Initial import from site-health-check·automated