Subresource Integrity

A browser check in which a script or stylesheet tag carries the expected hash of the file, and the browser refuses to use the file if it does not match.

In more detail

SRI stands for Subresource Integrity. The integrity attribute holds an algorithm and a Base64 hash, such as sha384-..., so a tampered file on a compromised CDN is blocked with a network error instead of running. Cross-origin files also need the crossorigin attribute.

Example

<script src="https://cdn.example.com/lib.js" integrity="sha384-..." crossorigin="anonymous"></script>

Related terms

Taught in

References