Why does the browser block a CDN script with the correct hash if crossorigin is missing?
Because without `crossorigin="anonymous"` on an origin different from the page's own, the response arrives opaque under CORS rules, and an opaque response does not expose its bytes for the browser to compute any hash; the integrity check has no way to happen, so the resource is refused regardless of whether the hash is actually correct.
Do I need to change the hash every time the CDN updates the library?
Yes. `integrity` locks the exact file at that URL at the moment the hash was generated; if the CDN publishes a new version at the same address, or fixes a bug in the file, the hash changes and the page stops loading the resource until `integrity` is recalculated for the new content.
SHA-256, SHA-384 or SHA-512, which algorithm should I pick?
All three protect equally against file tampering, because any single-byte change already alters the resulting hash under all of them; SHA-384 is the most common choice because it is what most CDN hash generators offer by default, not because SHA-256 is unsafe for this use.
Does SRI work for a script hosted on my own domain?
It does, but the `crossorigin` attribute stops being necessary when the resource shares the page's own origin, since there is no CORS restriction to work around; `integrity` alone already guarantees the browser rejects the script if the local file changes without the hash being updated.