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).
frontend ruleP2universalStack: HTML
performancepreloadimageshtml
Prefer HTML preload links over a JS hook for images
Preload images with <link rel=preload> in HTML rather than a custom hook; scope them with media queries so only viewport-relevant images load.
PR: hegnar-zephr-components · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetsx
| 1 | // custom hook imperatively preloads every image |
| 2 | usePreloadImages([desktopA, desktopB, mobileA, mobileB]); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codehtml
| 1 | <link rel="preload" as="image" href="/hero-desktop.png" media="(min-width: 641px)" /> |
| 2 | <link rel="preload" as="image" href="/hero-mobile.png" media="(max-width: 640px)" /> |
Explanation (EN)
Objašnjenje (HR)