Every third-party script on a commercial web page is a small act of trust extended to a stranger. The analytics tag, the chat widget, the A/B testing library, the payment processor's iframe helper, the tag manager container that itself pulls in a dozen more files: each one runs with the same privileges as the site's own code. It can read the DOM, touch cookies, read keystrokes inside form fields, and ship anything it finds to a server the site owner has never logged into. An audit is the process of deciding, with evidence, whether that trust is warranted.
The trouble is that "audit" sounds like a compliance ritual, a checkbox in a vendor questionnaire, and most teams treat it that way. A real audit is closer to forensic accounting: enumerate what is actually loading, trace who controls each byte, and test what each file can do once it is running.
Inventory first, opinions second
Nothing useful happens until the actual script inventory is known, and the inventory is almost always larger than the marketing team believes. Load a representative page in a browser with the network panel open, filter to JavaScript, and disable the cache. Then do it again on the checkout page, the account settings page, and a logged-in dashboard if one exists. The list will differ by page, and the logged-in view will often reveal scripts that never appear to anonymous visitors.
A surprising share of scripts arrive through a tag manager, which means the page source shows one container file and the container injects everything else at runtime. That distinction matters enormously for the audit, because a container tag can be added by someone in a marketing interface with no code review at all. The inventory has to capture the container's output, not just the script tags in the HTML.
Record for each script: the host domain, the version or build hash if visible, who inside the organization requested it, and the business purpose. A script with no named owner and no stated purpose is the first finding of the audit, before any technical analysis begins.
The domain in the src attribute proves very little
A script loaded from a vendor's own domain looks reassuring. The file at that address quite often loads a second file, and a third, and the chain terminates somewhere unexpected. Vendors chain to their own CDNs, to sub-processors, to advertising exchanges bought last quarter. The browser's network log shows the full chain, and a domain that appears at the end of it but nowhere in the page source deserves a hard question about who put it there.
Subresource integrity attributes are the clean control here: a hash in the markup that causes the browser to refuse a file whose contents changed. A script tag with an integrity hash cannot be quietly swapped by a compromised CDN. Most marketing tags do not carry one, because vendors ship updates constantly and the hash would break them. That absence is itself information, a straightforward statement that the file's contents are trusted to change without notice.
Reading the code for what it can reach
Minified vendor code is not meant to be read line by line, but it can be skimmed for capability. Search the file for cookie access, for calls that read form fields, for postMessage listeners, for dynamic script injection, for base64 blobs that get decoded and executed. A chat widget that reads the value of every input on the page is doing something a chat widget does not need to do, and the audit should say so plainly.
The most productive single question is what the script can reach from where it sits. A script served from the site's own origin inherits the site's cookies and session context. A script served from a vendor domain runs in a different origin and is blocked from reading the main site's cookies by the browser, unless the site has gone out of its way to weaken that boundary. The audit should rank findings by this exposure, because a chat widget on the vendor's own domain is a materially smaller problem than the same widget proxied through the site's domain to dodge ad blockers.
That proxying pattern, common enough now that it has its own acronym, moves third-party code onto the first-party origin so tracking survives blocker lists. It works. It also hands the vendor the keys to the front door, and any audit that finds it should flag it at the top of the report.
Watching what a script does after it loads
Static reading catches carelessness. Runtime observation catches behavior. Open the page with the browser's performance and network tools recording, interact with it the way a customer would, and watch what gets sent and when. A script that fires a request the instant a field in the payment form gains focus is capturing keystrokes, or at least has the machinery to. A script that phones home on every scroll event is building a behavioral profile.
Content Security Policy is the audit's best laboratory. Deploy a report-only policy that restricts script sources to a short allowlist, then browse the site normally and read the violation reports. Every blocked request names a domain the policy did not anticipate, and that list is a live inventory of what the site actually loads. Tightening the policy afterward is the enforcement phase, and the reports keep arriving as vendors change their infrastructure.
The same technique with a stricter policy in a staging environment will break things, and the breakage is instructive. When the page goes blank because a required script was blocked, the dependency map is suddenly visible in a way no spreadsheet captured.
Version pinning and the update nobody reviewed
A script loaded from a vendor's "latest" URL is a script the vendor can change at any hour. The audit should note whether the site pins a version. Pinning is not a cure, since old versions accumulate their own vulnerabilities, but it converts an invisible change into a deliberate one. The middle path, pinning with a scheduled review, means someone has to actually look at the diff, and in practice that review gets skipped until an incident forces it.
The uncomfortable arithmetic is that a script reviewed in March may be a different file by June with the same URL. An audit is a snapshot of a moving target, and the report should state the date of the snapshot prominently. Re-auditing on a schedule, quarterly for the high-exposure scripts and annually for the rest, is the only way the snapshot stays honest.
What the vendor questionnaire will not tell
Security questionnaires ask about encryption at rest, SOC 2 status, incident response timelines. They rarely ask the question that matters for a browser script: what does the file do inside the customer's session? A vendor can hold every certification and still ship a tag that reads the page's form fields or pulls in a fourth-party advertising pixel to monetize its free tier.
The useful vendor questions are narrower and more concrete. Does the script read DOM content outside its own widget container? Does it set or read first-party cookies? Does it load any additional domains at runtime, and can the vendor list them? Does the vendor offer a self-hosted or proxied deployment, and what does that deployment change about data flow? A vendor who cannot answer the fourth-party question has not looked at its own supply chain, which is a finding in itself.
Removing the script that nobody can justify
The most common audit outcome is not a dramatic vulnerability. It is a list of scripts that no one can defend: a heatmap tool from a pilot two years ago, a personalization engine whose contract lapsed, a retargeting pixel added by an agency that no longer works with the company. Each one still loads on every page load, still slows the site, still runs with full privileges, and still reports to a company that may have changed hands or gone dark.
Deleting these is the cheapest risk reduction available, and it is usually blocked by the same force that created the problem: nobody wants to be the person who removed the tag that turned out to matter. The audit gives that person cover. A written record that the script had no owner, no documented purpose, and no measurable effect is the evidence needed to switch it off, and a two-week observation window after removal will settle whether anything actually broke.
The sites that come out of an audit in good shape share a habit worth naming. They treat every script as a small dependency with a named owner and an expiry date, review the tag manager like a code repository, and keep a current map of which vendor touches which page. None of that is exotic. It just requires someone to look at the network panel once a quarter and ask the vendor, in writing, who else is running inside the file.
An audit report that ends with a count of findings and no removals is a document, not a result. The useful version ends with a shorter list of scripts than it started with, and a page that loads a little faster because of it.
