Skip to content
script-src.com
script-src.com
EN / FR

Content-Security-Policy

script-src

The script-src directive controls which sources a browser may load and execute JavaScript from. It is the core CSP directive for stopping cross-site scripting: once it is set, an injected script will not run unless you have explicitly allowed it.

response header
Content-Security-Policy:
  script-src 'self' https://cdn.example.com 'nonce-r4nd0m';

Allows same-origin scripts, one trusted CDN, and a single nonced inline script. Everything else is blocked.

Source values

Full reference →
ValueMeaning
'self'Scripts from the page's own origin.
'none'Block every script source.
https://hostAn explicit host you choose to trust.
'nonce-…'One inline script tagged with a matching nonce.
'sha256-…'One inline script whose contents match this hash.
'strict-dynamic'Trust scripts loaded by already-trusted scripts.

Documentation

Checking a whole policy

This site documents one directive. To evaluate an entire Content-Security-Policy, including every directive, its fallbacks, and known bypasses, run it through CentralCSP's CSP evaluator.