Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
fullstack ruleP2universalStack: JavaScript/HTTP
httpperformancenetworkingimages
Use a HEAD request to check resource existence
To verify a URL exists without downloading its body (and to avoid fetching an image twice), issue a HEAD request — or better, handle image fallback declaratively via onError.
PR: hegnar-components · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | const res = await fetch(logo); // downloads full body just to check it exists |
| 2 | if (res.ok) use(logo); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const res = await fetch(logo, { method: 'HEAD' }); |
| 2 | if (res.ok) use(logo); |
| 3 | // or declaratively: <img src={logo} onError={e => { e.currentTarget.src = fallback; }} /> |
Explanation (EN)
Objašnjenje (HR)