Concepts

CSP script-src

Try the free JavaScript compiler

Restricts execution and fetching of scripts according to the specified source list. A meta fixture only tests the newly inserted inline script.

Formal Syntax & Structure

javascript syntaxjavascript
Content-Security-Policy: script-src 'none'

Working Example

Example Snippetjavascript
(async () => {const m=document.createElement("meta");m.httpEquiv="Content-Security-Policy";m.content="script-src 'none'";document.head.append(m);const script=document.createElement("script");script.textContent="document.body.dataset.demo='ran'";document.head.append(script);console.log(document.body.dataset.demo===undefined);})()
JavaScript Reference