Context
Context. A script that needs data the template has already rendered should get it from the page, not from a second request. A request made on load waits for the HTML, then the script, then its own round trip, and the page shows the wrong numbers until it returns. Put the data in the page as JSON inside a <script type="application/json"> tag: it is data, not code, so it needs no CSP nonce, and the script reads it synchronously. The one rule is about caching: only seed what is the same for every visitor, because a cached page is served to everyone.