Custom scripts
Paths here are relative to your selected site root, not necessarily the repository root. Every.js file outside blog/, changelog/, snippets/, public/, styles/ and slots/ runs on every page, whether it’s script.js, a file in a scripts/ folder or a file like analytics.js at the site root. They’re the JavaScript counterpart to custom CSS, while a .js file in snippets/, blog/ or changelog/ is a component you import instead. Files in public/ aren’t automatically loaded as page scripts.
defer from your site’s own address, and the scripts run in the order shown above after the browser parses the HTML.
- These files are plain browser JavaScript rather than modules, so
importandexportdon’t work in them, and you load a library from another host withdocument.createElement("script")and add that host toallowedOrigins. - The build checks the syntax without running your scripts, and a syntax error fails the build with the file name and line number.
- Your MDX can’t import these files, so for a component, use a snippet in
snippets/instead.
script.js or under scripts/. Notra doesn’t run your repository’s package scripts or serve an arbitrary app build. Keep supporting assets in public/ and check the allowed file types; .html, .mjs and .wasm files aren’t collected.
Code that requires dynamic inline scripts or eval won’t work with the default Content-Security-Policy. Adding an origin allows that host, not those execution methods. Choose compatible output or host the app separately rather than disabling the policy to make a bundle run.
scripts/external-links.js
Consent
With the c15t cookie banner on, list tracking scripts underintegrations.c15t.scripts so they wait until a visitor allows them. Scripts you don’t list keep loading on every page.
Content-Security-Policy
Notra builds aContent-Security-Policy header for every page from your repository, and it decides where scripts can load from and which servers they can connect to.
- Scripts can come from your site, the analytics integrations you turned on and your
allowedOrigins. Notra hashes every inline script that was on the page at build time into the policy, so the browser blocks any inline script injected later. - Connections from
fetch, beacons and WebSockets may go to your site, your integrations, your c15t backend and yourallowedOrigins. - The policy doesn’t limit images, styles, fonts, videos and embeds, so posts can still show images and videos from anywhere.
blog.json
https:// or wss:// and have no path, and https://*.example.com covers every subdomain. A wss:// origin only allows connections rather than scripts, and you can list up to 32 origins.
WebAssembly
Animation runtimes like Rive compile WebAssembly, which the policy blocks by default. Allow it withwebAssembly:
blog.json
'wasm-unsafe-eval' to the policy. JavaScript eval stays blocked. Put the .wasm and .riv files in public/ so they load from your site, or add the runtime’s CDN to allowedOrigins.
To turn the policy off, set contentSecurityPolicy to false:
blog.json
allowedOrigins.