Courses / Frontend Security & Observability
2. Subresource Integrity (SRI)
Using SRI attributes to ensure external script/style integrity on the client.
JavaScript
Subresource Integrity (SRI)
An HTML feature that ensures a fetched script or stylesheet hasn't been tampered with by checking a cryptographic hash before executing it.
"I want to load a CDN script but ensure it hasn't been altered by a network attacker."
SRI adds an integrity attribute (a base64 hash) to <script> or <link> tags so the browser verifies the resource matches the hash and blocks it if not.
"I want to load a CDN script but ensure it hasn't been altered by a network attacker."
SRI adds an integrity attribute (a base64 hash) to <script> or <link> tags so the browser verifies the resource matches the hash and blocks it if not.