Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Keep a resource hint gate-independent and no later than its earliest consumer
A preconnect/preload must survive whatever gating removes unrelated partials (never park it inside an ad block), but it must also stay at the top of <head>, ahead of the first script that depends on that origin (an ad stack that waits on the CMP needs the consent origin warm first). Moving a hint next to its own script can push it too late; keep it early and outside the gate instead.
Bad example
| 1 | {# gated ad partial #} |
| 2 | <link rel="preconnect" href="https://cdn.privacy-mgmt.com" crossorigin> {# dropped on ad-free #} |
| 3 | ... |
| 4 | {# or: 200 lines lower, next to the CMP script — too late for the ad stack #} |
Explanation (EN)
Objašnjenje (HR)
Good example
| 1 | {# top of head, outside the ad gate #} |
| 2 | <link rel="preconnect" href="https://cdn.privacy-mgmt.com" crossorigin> |
| 3 | {% if not res.locals.adFree %}{% include 'common/livewrapped.njk' %}...{% endif %} |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Two reviewers, two halves of the rule: one flagged the hint being dropped by the ad gate, the other flagged it being moved too late. Position in <head> is part of a hint's correctness.