Skip to content

Performance8 min read

Audit WordPress third party scripts without breaking key flows

Inventory WordPress third party scripts, measure network and main-thread cost, test one change at a time, and remove code without breaking key flows.

Portrait of Hamza Ahmad AslamBy AI & WordPress Developer | Speed Optimization & Site Security

Web page ship towed by a fleet of tugboats on taut ropes while an inspector's spotlight finds the heaviest lines
Illustration generated with ChatGPT
On this page
  1. Build a WordPress third party scripts inventory first
  2. Find every external request and its initiator
  3. Measure network cost and main-thread execution separately
  4. Treat unused JavaScript as a clue, not a removal verdict
  5. Test one removal or loading change at a time
  6. Compare waterfalls with a controlled worksheet
  7. Verify consent, forms, tracking, and checkout after every change
  8. Decide which scripts can be removed
  9. Use the audit result for the next fix
  10. Frequently asked questions

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 (opens in a new tab) 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.

IDProvider or scriptDomain or hostAdded byBusiness ownerPurposePages or triggerDepends onTransfer sizeMain-thread timeCandidate actionProof required
AKeep / remove / conditional / delay
BKeep / remove / conditional / delay
CKeep / 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 (opens in a new tab).

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:

  1. Record the domain and request name.
  2. Check Initiator to find what caused the request.
  3. Group related requests under one provider or business dependency.
  4. Record transferred size and request timing.
  5. 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 (opens in a new tab) 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 (opens in a new tab) shows how to inspect that data.

Main-thread time matters because JavaScript work can delay input handling. Google’s INP optimization guide (opens in a new tab) 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 (opens in a new tab) 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:

TestDependency changedPage and flowBaseline requestsCandidate requestsBaseline transferCandidate transferBaseline main-thread timeCandidate main-thread timeExpected resultBusiness 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.

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:

FlowWhat to doExpected resultPass or failEvidence
ConsentLoad with a fresh consent state, change the choice, then continue browsingTags that should wait for consent remain inactive until the allowed state; required site behavior still works
FormsLoad, trigger validation, submit valid data, reach the success stateValidation, submission, success UI, and required tracking still work
TrackingVisit the target page and complete the tracked actionThe expected analytics or marketing event is still sent once, at the intended step
CheckoutAdd an item, reach checkout, complete the configured test purchase flow, and reach confirmationCart, 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.

Frequently asked questions

How do I find which third-party scripts are slowing down WordPress?

Use DevTools Network to list requests and their initiators, then confirm which off-origin domains belong to outside providers. Record the same flow in Performance to see main-thread cost, then group confirmed third-party requests by provider and business purpose.

How can I reduce the impact of Google Tag Manager and other third-party code?

Audit the tags that the container fires, remove abandoned tags, and narrow tags to the pages or events that need them. Delay the container or individual tags only after you verify consent state, expected events, forms, and checkout under the new timing.

How do I identify unused third-party scripts on a WordPress site?

Use Coverage to find code that stayed unused during a recorded page load and interaction flow, then check other routes and states before deciding. “Unused in this recording” does not prove that a script is unused across the site.

Can I defer third-party scripts without breaking analytics or tracking?

Sometimes, but deferral changes when code becomes available. Test the exact analytics events and consent sequence you depend on, and compare them against the baseline before publishing the change.

Which third-party scripts can I safely remove from WordPress?

Remove a dependency when its owner confirms the business purpose has ended, no required feature depends on it, and your controlled flow tests still produce the expected results. Keep the test record because later site changes may alter that dependency picture.

How this article was made: drafted with AI assistance from a researched brief, then checked against primary documentation before publishing.

Enjoyed this? Get the next article by email.

Occasional, useful posts. No spam, and you can unsubscribe anytime.

  • Magnifier over two score cards, green lab results beside mixed amber field results, linked by a tape measurePerformance

    8 min read

    PageSpeed good, Core Web Vitals failed: read the right data

    If PageSpeed looks good but Core Web Vitals failed, check the data source before you change WordPress. The green Lighthouse score and the failed Core Web Vitals assessment can both be correct because they measure different populations, time periods and conditions.

    • WordPress
    • Core Web Vitals
    • Performance
    Read article
  • Stagehands carry the large hero painting onstage first under a spotlight and a stopwatch while smaller frames wait in the wings.Performance

    7 min read

    WordPress LCP image optimization: make the largest image load first

    A slow WordPress LCP image usually needs three things: early discovery, high fetch priority, and a file sized for the space it occupies. Find the actual LCP element first, then remove accidental lazy loading, fix responsive image markup, preload late-discovered backgrounds, and retest.

    • WordPress
    • Core Web Vitals
    • Performance
    Read article