Reduce Third-Party Code WordPress - Keep External Scripts From Slowing You Down (2026)

Third-party code is anything your pages load from other companies' servers: analytics, ads, chat, embeds, fonts and pixels. It's often the heaviest part of a WordPress page, and you don't control how it's built.

Why Third-Party Code Is a Problem

Each external service adds requests, connections to new domains and often a lot of JavaScript. Because the code lives on someone else's server, you can't optimize it directly, and it can change without warning.

PageSpeed Insights shows this in its 3rd parties insight, which replaced the older "Reduce the impact of third-party code" audit. It lists each external service with its transfer size and how much main-thread time it uses.

Step 1: Take an Inventory

Illustration for Step 1: Take an Inventory on the Reduce Third-Party Code WordPress page, showing a code diagram
  1. Run PageSpeed Insights

    Open the 3rd parties insight and note each service, its size and main-thread time.

  2. Check your tag manager

    List every tag and whether it's still needed.

  3. Check plugins that add services

    Chat, reviews, social feeds, popups and analytics plugins often load external code.

  4. Check embeds

    YouTube, maps, social posts and forms from other platforms.

  5. Assign an owner

    For each service, note who needs it and why.

Step 2: Decide What to Do With Each Service

Third-party services and what to do
Service TypeTypical ImpactRecommended Approach
AnalyticsModerateKeep one tool; delay where acceptable; avoid duplicates
Tag manager with many tagsCan be highRemove old tags; trigger tags only where needed
AdsHighReserve space; limit ad density; lazy load below-the-fold slots
Chat widgetsHighDelay until interaction, or load on key pages only
Social embeds and feedsModerate to highUse static images or links; lazy load embeds
YouTube and video embedsHighUse a preview image that loads the player on click
Google MapsHighUse a static map image linking to the full map
Google FontsLow to moderateSelf-host fonts
Marketing pixelsModerateConsolidate; delay until interaction
Review and testimonial widgetsModerateLoad where visible; delay or lazy load

Step 3: Delay Non-Essential Scripts

Most third-party scripts don't need to run before someone can read your page. Delaying them until the first interaction removes them from the critical loading period.

WP Rocket's Delay JavaScript execution includes third-party scripts and has one-click exclusions for services that must run early, like some consent tools. Check that analytics still records visits correctly after delaying, since visitors who leave without interacting won't trigger delayed tags.

Step 4: Replace Heavy Embeds With Facades

Illustration for Step 4: Replace Heavy Embeds With Facades on the Reduce Third-Party Code WordPress page, showing a code diagram

A facade is a lightweight placeholder, usually an image, that looks like the embed and loads the real thing when clicked.

Step 5: Host What You Can Locally

Some third-party resources can be served from your own domain:

Step 6: Connect Early to What Remains

For external domains you need early, preconnect hints let the browser set up connections ahead of time. WP Rocket adds preconnect hints for external domains automatically. See preconnect and DNS prefetch.

Illustration for Consent Banners and Third-Party Code on the Reduce Third-Party Code WordPress page, showing a code diagram

If you use a cookie consent tool, it often controls when third-party scripts load. That can help performance, because tracking scripts don't load until a visitor consents, but the consent tool itself is a third-party script that usually needs to run early.

Measuring the Payoff

What to track before and after
MetricWhere to LookWhat to Expect
Third-party main-thread timePageSpeed Insights 3rd parties insightLarge drop after removing or delaying services
Total Blocking TimeLighthouse lab testFalls as third-party scripts leave the initial load
INPField data in PageSpeed Insights and Search ConsoleImproves over four weeks
Number of requests and domainsNetwork panel or waterfallFewer domains and requests on load
Business metricsYour analyticsCheck conversions and tracking still work

Building a Third-Party Policy

Third-party code tends to creep back as marketing tools are added. A simple policy helps:

Ads: A Special Case

Ad-supported sites can't simply remove third-party code. Balance revenue and speed:

See speeding up WordPress with ads.

A Worked Example

A local business site's 3rd parties insight shows a chat widget, an embedded Google Map on every page, a review carousel, two analytics tools and Facebook and LinkedIn pixels. Together they dominate main-thread time on mobile.

The owner removes the duplicate analytics tool, moves the map to the contact page as a static image, delays the chat widget, review carousel and pixels until interaction, and keeps one analytics tag. Third-party main-thread time drops dramatically and INP moves into the good range.

Reduce Third-Party Code WordPress FAQ

What is third-party code?

Any script, font, embed or resource your page loads from another company's server, like analytics, ads, chat, maps and social widgets.

How do I see which third parties slow my site?

PageSpeed Insights' 3rd parties insight lists each service with its size and main-thread time.

Will delaying third-party scripts affect analytics?

It can reduce recorded visits from people who leave without interacting. Many sites accept this trade-off or keep analytics excluded from delay.

Can WP Rocket reduce third-party code impact?

Yes. Delay JavaScript execution, YouTube preview images, lazy loading for iframes, self-hosted Google Fonts and automatic preconnect all help.