Pin third-party scripts with integrity hashes
Make the browser refuse a CDN script that was changed after you added it.
What it is
Subresource Integrity (SRI) adds a hash of the expected file to the script tag. If the file changes, the browser does not run it.
Why it matters
Several large breaches came from a compromised CDN or analytics script that then ran on thousands of sites.
How to fix it
HTML
<script src="https://cdn.jsdelivr.net/npm/lib@1.2.3/dist/lib.min.js" integrity="sha384-..." crossorigin="anonymous"></script>
Only use SRI with fixed-version URLs. For scripts that change on purpose (some analytics tags), self-host or accept the risk knowingly.
Does your site have this problem?
Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.