CS Fundamentals Trainer · JavaScript · Security
A page includes <script src="https://cdn.example/lib.js" integrity="sha384-..." crossorigin="anonymous">, but the CDN now serves a file…
A page includes `<script src="https://cdn.example/lib.js" integrity="sha384-..." crossorigin="anonymous">`, but the CDN now serves a file whose hash doesn't match. What does the browser do?
- It executes the script but logs a console warning, since integrity checks are advisory.
- It refuses to execute the script and fires an `error` event on the `<script>` element.
- It downloads the same path from the page's own origin as a fallback and runs that.
- It executes the script in a sandbox without access to the page's DOM.
Difficulty: easy