Originally published at hamzaahmadaslam.com.
How this article was made: drafted with AI assistance from a researched brief, then checked against primary documentation before publishing.
To audit WordPress third party scripts, start by listing every external dependency and the business owner who still needs it, then measure its network and main-thread cost. Change one dependency at a time, compare the same page and user flow, and retest consent, forms, analytics, and checkout before you remove or delay anything.
Build a WordPress third party scripts inventory first
Third-party JavaScript is code you did not author and that is served by another provider. It can add network requests, CPU work, rendering delays, and dependencies on servers you do not control. Google’s third-party JavaScript performance guide also recommends routine audits and removing redundant providers.
Do not stop at the domain name. Record who added the dependency, who owns its business purpose, and what would fail if it disappeared. A marketing pixel with no current campaign owner deserves a different decision from a payment script that checkout needs.
Use this worksheet as the working record. The rows are blank on purpose so your measurements are your own.
| ID | Provider or script | Domain or host | Added by | Business owner | Purpose | Pages or trigger | Depends on | Transfer size | Main-thread time | Candidate action | Proof required |
|---|---|---|---|---|---|---|---|---|---|---|---|
| A | Keep / remove / conditional / delay | ||||||||||
| B | Keep / remove / conditional / delay | ||||||||||
| C | Keep / remove / conditional / delay |
Start with the pages that matter to the business: the home page, a key landing page, a form page, a product page, cart, checkout, and the order confirmation page where applicable. Add other routes when a script appears only there.
The “Added by” field matters because an external request can come from a plugin, theme, tag manager, embedded widget, custom snippet, or another third-party script. The “Business owner” field names the person who can confirm the tool is still needed.
Find every external request and its initiator
Open Chrome DevTools, load the page, then use the Network panel. The Network panel’s More filters > 3rd-party requests option shows requests whose origin differs from the page’s origin. That list can include your own CDN or subdomains, so confirm who operates each domain before you add it to the inventory. Its request table can also show Domain, Initiator, Size, Time, and the Waterfall, which makes it useful for building the inventory. See the current Network panel reference.
For a controlled first-load comparison, use the same browser, page, login state, consent state, network setting, and cache setting for both variants. If you use DevTools’ Disable cache setting, keep it enabled for both runs. Do not compare a cold baseline with a warm-cache candidate.
Work through each third-party request:
- Record the domain and request name.
- Check Initiator to find what caused the request.
- Group related requests under one provider or business dependency.
- Record transferred size and request timing.
- Follow the page’s normal user flow so late requests also appear.
A tag manager is a common source of indirection. Google Tag Manager can deploy Google and third-party tags from one container, so gtm.js is only the loader you see first. Inventory the tags it causes to fire as separate dependencies, not as one generic “GTM” row. Google’s Tag Manager overview describes the container as a system for configuring and deploying tags.
Measure network cost and main-thread execution separately
A large download and a CPU-heavy script are different problems. Record both.
In the Network panel, compare transfer size, request duration, request order, and dependencies in the waterfall. A provider that makes many follow-up requests may cost more than its first JavaScript file suggests.
Then record the same page and user flow in the Performance panel. The current panel can show first-party and third-party entities, transfer size, and main-thread time for the selected range. Chrome 134 added the first-party and third-party summary table and the “Dim 3rd parties” control. The current Performance panel reference shows how to inspect that data.
Main-thread time matters because JavaScript work can delay input handling. Google’s INP optimization guide explains that script loading, parsing, compiling, and other work can contribute to input delay.
Do not turn this audit into a full INP investigation. If a specific click or typing interaction remains slow after you reduce third-party work, continue with finding the interaction behind poor WordPress INP.
Treat unused JavaScript as a clue, not a removal verdict
Chrome’s Coverage panel records used and unused bytes while you load and interact with a page. It is useful for finding files that ship much more code than the tested flow executes. The Coverage documentation explains that recording continues while you interact with the page.
That result is scoped to what you exercised. Code marked unused on a landing page may run after consent changes, a form error, a video play, a cart update, or another route.
For unused JavaScript on WordPress, pair Coverage with ownership and flow testing. A file becomes a removal candidate only after you can answer three questions:
- Which feature or measurement does it support?
- Which pages and states require it?
- Which owner still needs the result?
If nobody can answer the purpose, mark the row “owner unknown” instead of deleting it on production.
Test one removal or loading change at a time
A useful way to audit marketing scripts in WordPress is to change one dependency, then rerun the same measurement and business tests. Changing several tags together makes attribution weak because you cannot tell which change improved the waterfall or broke a flow.
Use staging or another controlled environment when removal can affect revenue, consent behavior, or data collection. For each candidate, choose one action:
- Remove it when the owner confirms the purpose has ended.
- Load it only on routes where the feature is used.
- Narrow a tag-manager trigger when a tag only belongs to a specific page or event.
- Delay it only when its timing is not required for the user flow or measurement you still need.
- Keep it when the business function depends on it and the cost is accepted.
When third-party scripts make a WordPress site slow, start with code that has weak business value and measurable browser cost, not whichever domain appears first in a report.
If you are checking WordPress Tag Manager performance, inspect the tags inside the container before you try to delay the container itself. A smaller set of active tags and tighter firing rules gives you a clearer system to test.
Compare waterfalls with a controlled worksheet
Use the same page, flow, cache state, consent state, and test setup for baseline and candidate runs. Make one code or configuration change between them.
Copy this comparison table into the ticket or pull request:
| Test | Dependency changed | Page and flow | Baseline requests | Candidate requests | Baseline transfer | Candidate transfer | Baseline main-thread time | Candidate main-thread time | Expected result | Business checks |
|---|---|---|---|---|---|---|---|---|---|---|
| Fewer requests or less work without lost function |
Use these formulas when you summarize a comparison:
Request delta = candidate request count - baseline request count
Transfer delta = candidate transferred bytes - baseline transferred bytes
Main-thread delta = candidate main-thread time - baseline main-thread time
Negative values mean the candidate used fewer requests, fewer transferred bytes, or less main-thread time. Do not treat one faster waterfall as proof by itself. The change still has to pass the business checks below.
Verify consent, forms, tracking, and checkout after every change
A dependency is removable only within the scope you tested. Report that scope in the change record.
Use this test matrix after each removal, conditional-load rule, or delay:
| Flow | What to do | Expected result | Pass or fail | Evidence |
|---|---|---|---|---|
| Consent | Load with a fresh consent state, change the choice, then continue browsing | Tags that should wait for consent remain inactive until the allowed state; required site behavior still works | ||
| Forms | Load, trigger validation, submit valid data, reach the success state | Validation, submission, success UI, and required tracking still work | ||
| Tracking | Visit the target page and complete the tracked action | The expected analytics or marketing event is still sent once, at the intended step | ||
| Checkout | Add an item, reach checkout, complete the configured test purchase flow, and reach confirmation | Cart, checkout UI, payment test flow, order creation, and required measurement still work |
Add any site-specific flow that the dependency touches, such as chat, booking, video, search, account login, or lead routing. Record the flows you tested instead of using a generic “regression tested” note.
Late-loading widgets and embeds can also move page content. If a loading change creates visual movement, use finding the element that causes layout shifts in WordPress rather than treating that as a script-inventory problem.
Decide which scripts can be removed
Do not classify scripts by brand. Classify each dependency by purpose, ownership, cost, and test evidence.
A strong removal candidate has all of these traits:
- No current business owner needs its output.
- No required feature depends on it.
- It is absent from the flows where it was expected to matter.
- The controlled candidate run reduces network or main-thread work.
- Consent, forms, tracking, checkout, and other affected flows still produce the expected result.
A script with high cost but an active business purpose may need conditional loading instead. A low-cost script with no owner or purpose can still be clutter worth removing.
Deferring a script is also a behavior change. Analytics can miss early events, consent logic can run in the wrong order, and UI code can appear late if timing changes. Treat defer or delay rules as experiments with the same verification matrix.
Use the audit result for the next fix
If the dependency belongs to your own front-end code rather than an external provider, move that work to the codebase and follow the site’s guide to loading ES modules with WordPress Script Modules. Keep this audit focused on ownership, external dependencies, and removal decisions.
If the remaining problem spans third-party code, theme work, plugins, and measurement across key routes, WordPress performance optimization can take the audit through implementation without mixing this inventory with unrelated performance work.
Top comments (0)