Subresource Integrity

Last updatedView as Markdown

Pin the scripts and stylesheets WordPress prints to the bytes they should contain, so the browser refuses a file that has changed. The plugin hashes the site's own files from disk and adds integrity and crossorigin to their tags.

Turn pinning on

  1. Find the assets

    Under Integrity, choose Check home page. WordPress loads its own home page once and records what it prints. Assets are also recorded as pages are served while pinning is on.

  2. Pin the site’s own files

    Switch on Pin this site’s own files and choose Save. The header badge changes to Pinning on.

  3. Decide about remote files

    Optionally switch on Pin remote files too. CDN files are fetched in the background and pinned only when their host allows cross-origin checks.

  4. Check the table

    Each asset shows Pinned, or why it is not. Fix or exclude anything you do not want pinned.

How assets are hashed

This site's filesRemote files
Source of the bytesThe file on diskA background fetch, about 30 seconds after the file is first seen
AlgorithmSHA-384SHA-384
Re-hashedWhenever the file's modification time changes, on the next page that prints itWith Hash again
Limits.js, .mjs and .css files up to 5 MBUp to 5 MB, three redirects
Pinned whenPinning is onPin remote files too is on and the host sends Access-Control-Allow-Origin of * or the site's own origin

A URL counts as this site's when it is under the content, plugins, includes, site or home URL and resolves to a file inside the matching directory. Paths that climb out of those directories with .. are refused. The consepo_csp_scanner_asset_bases filter changes the list; see Hooks and constants.

The plugin adds integrity and, when the tag has none, crossorigin="anonymous". It leaves tags that already carry an integrity attribute alone.

html Page source
<link crossorigin="anonymous" integrity="sha384-FX5lt8LPJCa0tSh1GD8ii7WfZhgsC5PQpikPwaycOPT9mZCpeCvz5MCyle101LiZ" rel='stylesheet' id='dashicons-css' href='http://localhost:9400/wp-includes/css/dashicons.min.css?ver=7.1.4' media='all' />
A pinned core stylesheet on a WordPress 7.1 test site.

Statuses

StatusMeansWhat to do
PinnedHashed, and pinned on the pageNothing
hashedHashed but not pinned: pinning is off, the handle is excluded, or it is remote and remote pinning is offTurn pinning on, or leave it
pendingWaiting for the background fetchWait, or reload the table
skipped: volatileThe host changes its code behind the same URL, so a pinned hash would break the pageAllow the host in the policy instead
skipped: no-corsThe host sends no CORS header, so the browser could not check a hash and would block the fileLeave it unpinned
skipped: too-largeLarger than 5 MBLeave it unpinned
errorfetch-failed, http- and a status code, missing-file or unreadableCheck the URL, then Hash again

Hovering a status shows the reason in words. Hosts treated as volatile include Google Tag Manager and Analytics, DoubleClick, Facebook, Hotjar, Segment, Intercom, Microsoft Clarity, LinkedIn, TikTok, HubSpot, Optimizely, Calendly and Stripe (js.stripe.com), matched with their subdomains.

Row actions

  • Hash again hashes the selected files from disk at once, and queues remote ones for the next background run.
  • Copy integrity copies the sha384-… value.
  • Never pin and Allow pinning exclude a handle from pinning, or include it again.

The inventory keeps up to 300 assets and drops the least recently seen beyond that.

Have a question about this page?

Linchpin assistant

Was this helpful?