Glossary
Subresource Integrity (SRI)
Definition
Subresource Integrity (SRI): A W3C web standard that lets a page give the expected cryptographic hash of a script or stylesheet in an integrity attribute, so the browser refuses a fetched file whose contents don't match, protecting sites from tampered CDN files.
Also known asSRIintegrity attributesubresource integrity hash
In short
Subresource Integrity (SRI) is a W3C browser feature that lets a web page state the expected cryptographic hash of a script or stylesheet in an integrity attribute. The browser hashes the file it downloads and refuses to use it if the value doesn't match, so a compromised CDN can't swap in malicious code. Cross-origin files also need CORS.
Key takeaways
- SRI pins a third-party file's exact contents with a hash in the integrity attribute.
- A mismatch means the browser refuses the file and fires an error event, so you can load a fallback.
- Files from another origin need crossorigin="anonymous" and a CORS header from the server.
- Pin exact versions. A file that changes in place breaks its hash.
- SRI checks what a file contains, not whether the page should load it. Pair it with CSP.
Last reviewed 4 December 2026 by Foxcolab Team
Subresource Integrity (SRI) is a browser feature that lets a page state the exact cryptographic hash a script or stylesheet must have. If the file fetched from a CDN or any other server doesn't match, the browser refuses to use it. The W3C Recommendation describes "a mechanism by which user agents may verify that a fetched resource has been delivered without unexpected manipulation." A Level 2 draft extends it.
How it looks#
This is the specification's own example:
<script src="https://example.com/example-framework.js"
integrity="sha384-Li9vy3DqF8tnTXuiaAJuML3ky+er10rcgNR/VqsVpcw+ThHmYcwiB1pbOxEbzJr7"
crossorigin="anonymous"></script>The integrity value names the hash function, then gives the file's hash in base64. The browser hashes what it downloads and compares. On a mismatch it treats the response as a network error and fires an error event, so your page can fall back to a copy you host yourself. SRI works on <script> and <link> (stylesheet) elements.
Why it matters#
Many sites load the same library from the same CDN. If that CDN is breached, every one of them runs the attacker's code, a classic supply chain attack. With SRI, the swapped file fails its check and never runs.
Mistakes people make#
- Leaving out CORS. The spec says "Subresource Integrity requires CORS and it is a logical error to attempt to use it without CORS." Add
crossorigin="anonymous", and the CDN must sendAccess-Control-Allow-Origin. - Pinning a moving file. A URL like
/latest/library.jschanges, and the hash breaks the day it updates. Pin an exact version. - Expecting it to decide what loads. SRI checks a file's contents, not whether the page should load it. A Content Security Policy controls that. Level 2 adds an Integrity-Policy header that can block scripts and styles that arrive without integrity metadata.
In Foxcolab#
Foxcolab Drive, Docs, Sheets, Notes, Whiteboard and Forms serve their own scripts from their own sites rather than from a shared CDN, and their Content Security Policy runs only scripts carrying a fresh nonce for each page load. When you embed a Foxcolab form on your website, the standard embed code loads embed.js from the Forms site. If your site's rules require an integrity hash on every outside script, turn on Use a plain iframe in Embed on your website. It adds no script to your page, for inline and full-page forms. See share, embed and prefill a form.
Keep exploring
Related terms
- Supply chain attackA supply chain attack reaches its target through a supplier, such as a software library, an update or a service provider, instead of attacking the target directly.
- Content Security Policy (CSP)A Content Security Policy tells the browser which scripts, frames and connections a page may use, so an injected script doesn't run. Here's a strict policy explained line by line.
- HashingHashing turns any data into a short, fixed-length fingerprint that can't be turned back. It's how services check passwords without storing them and how you confirm a file arrived intact.
- Cross-site scripting (XSS)Cross-site scripting lets an attacker run their own script inside a trusted website, in other people's browsers. Here are the three types, an example and the defenses that work.
- Same-origin policyThe same-origin policy stops a web page from reading data that belongs to another origin. Here's what counts as an origin, what the rule blocks, and where cookies differ.
Where Foxcolab uses it

Foxcolab
Private work tools, without the ads.
Mail, files, documents, spreadsheets and meetings in one account. Files, documents and spreadsheets are end-to-end encrypted.