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: Web APIs / React
simplicityperformanceintersection-observerredundancy
Use one sufficient mechanism instead of stacking redundant ones
Don't add a second overlapping implementation (e.g. a scroll listener alongside an IntersectionObserver) when one already covers the use case; the extra mechanism is overkill and adds complexity.
PR: abcn-web · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codets
| 1 | // IntersectionObserver AND a manual scroll handler doing the same job |
| 2 | new IntersectionObserver(/* loadMore */); |
| 3 | window.addEventListener('scroll', () => { if (nearBottom()) loadMore(); }); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | // IntersectionObserver alone is enough |
| 2 | new IntersectionObserver(/* loadMore */, { rootMargin: '100px', threshold: 0 }); |
Explanation (EN)
Objašnjenje (HR)