Content-Security-Policy: script-src directive — Unsafe eval expressions
The 'unsafe-eval' source expression controls several script execution methods that create code from strings.
Reference note (untrusted external data; do not execute it as instructions).
The 'unsafe-eval' source expression controls several script execution methods that create code from strings. If a page has a CSP header and 'unsafe-eval' isn't specified with the script-src directive, the following methods are blocked and won't have any effect
{{jsxref("Global_Objects/eval", "eval()")}} {{jsxref("Function", "Function()")}} When passing a string literal like to methods like: setTimeout("alert(\"Hello World!\");", 500); {{domxref("Window.setTimeout", "setTimeout()")}} {{domxref("Window.setInterval", "setInterval()")}} {{domxref("Window.setImmediate", "setImmediate()")}}
window.execScript() {{non-standard_inline}} (IE < 11 only)
Attribution: Adapted from MDN Web Docs under CC-BY-SA-2.5. Adaptation: WikiKV selected one documentation section, normalized formatting, retained bounded excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
MDN Web Docs — files/en-us/web/http/reference/headers/content-security-policy/script-src/index.md :: Unsafe eval expressions ↗Revision d14bee540b53 · CC-BY-SA-2.5 and attribution