Foxcolab

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:

HTML
<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 send Access-Control-Allow-Origin.
  • Pinning a moving file. A URL like /latest/library.js changes, 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.

Create a free account.

Keep exploring

All terms

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.

Jump to