{"id":2234894,"date":"2020-05-05T11:05:00","date_gmt":"2020-05-05T09:05:00","guid":{"rendered":"https:\/\/wp-rocket.me\/?p=2234894"},"modified":"2024-09-12T15:37:03","modified_gmt":"2024-09-12T13:37:03","slug":"third-party-scripts","status":"publish","type":"post","link":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/","title":{"rendered":"How to Reduce the Impact of Third-Party Scripts on WordPress"},"content":{"rendered":"<p>Third-party scripts add a wide range of useful features to your website, making it more interactive, dynamic, and interlinked. Features like analytics, ads, social media sharing buttons, video embeds \u2014 they\u2019re all possible thanks to third-party scripts. Some of these features could be essential for your website\u2019s functionality or monetization.<br><\/p><p>However, third-party scripts are also one of the leading causes of performance slowdowns on websites. They\u2019re usually the costliest resource during page load. A few of these scripts may also pose security and privacy risks.<br><\/p><p>In this article, you\u2019ll learn the basics of third-party scripts, how they affect website performance, and what you can do to mitigate their negative effects.<br><\/p><p>Sounds interesting? Let\u2019s get started!<\/p><h2 class=\"wp-block-heading\">What Are Third-Party Scripts?<\/h2><p>\u2018Third-party scripts\u2019 refers to any script that you can directly embed into your website from a third-party vendor. They\u2019re not created by you, nor explicitly controlled by you, and are served from an external URL.<\/p><h3 class=\"wp-block-heading\">Where are Third-Party Scripts Used?<\/h3><p>Almost every website uses third-party scripts to add some functionality. A few of their most common uses are:<\/p><ul class=\"wp-block-list\"><li>Embedding videos (e.g. YouTube, Vimeo)<\/li><li>Adding social sharing buttons<\/li><li>Adding chat widgets<\/li><li>Embedding comment systems (e.g. Disqus)<\/li><li>Enabling web analytics (e.g. Google Analytics)<\/li><li>Embedding ads<\/li><li>Serving resources via Content Delivery Networks (CDNs)<\/li><li>Experimenting with A\/B testing scripts<\/li><li>Adding helper libraries (e.g. animation, functional libraries, etc.)<\/li><\/ul><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Third-Party-JS-Scripts-Browser-Visual-Guide.png\" alt=\"The many uses of third-party scripts\" class=\"wp-image-2234942\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Third-Party-JS-Scripts-Browser-Visual-Guide.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Third-Party-JS-Scripts-Browser-Visual-Guide-300x225.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Third-Party-JS-Scripts-Browser-Visual-Guide-768x576.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>The many uses of third-party scripts<\/figcaption><\/figure><p>Developers can add powerful functionality to websites with just a few lines of code using third-party scripts. For example:&nbsp;<\/p><ul class=\"wp-block-list\"><li>Marketing teams can use reports from analytics and A\/B testing scripts to ground their business decisions on sound data.&nbsp;<\/li><li>Users can share an article they like to their favorite social network with just the click of a button.<\/li><li>Prospective customers can reach out to support or sales staff through the chat widget and get answers to their queries right away.<\/li><\/ul><p>The applications of third-party scripts are endless, but it just doesn\u2019t end there. If used without caution, third-party scripts can be problematic for privacy, security, and page performance.<\/p><h2 class=\"wp-block-heading\">The Cost of Third-Party JavaScript<\/h2><p>Third-party scripts are everywhere. According to the <a href=\"https:\/\/httparchive.org\/reports\/state-of-javascript\">State of JavaScript report by HTTPArchive<\/a>, the median number of external scripts requested by websites is <strong>20<\/strong> and their total size is around <strong>449 KB<\/strong>.<br><\/p><p>A whopping <strong>93.59%<\/strong> of web pages <a href=\"https:\/\/almanac.httparchive.org\/en\/2019\/third-parties#fig-1\">include at least one third-party resource<\/a>. Digging deeper into the same data shows that <strong>76%<\/strong> of websites track users with analytics scripts.<br><\/p><p>The worst impact of third-party scripts is delaying the <a href=\"https:\/\/docs.wp-rocket.me\/article\/108-render-blocking-javascript-and-css-pagespeed\">critical rendering path<\/a>, plus affecting your <a href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/\">Core Web Vitals scores<\/a>, starting from the <a href=\"https:\/\/wp-rocket.me\/google-core-web-vitals-wordpress\/\">FID grade<\/a>. <\/p><p>The critical rendering path is the set of actions a browser makes to assemble HTML, CSS, and JavaScript into a living, usable website. Naturally, the payload size of the third-party scripts plays a major role here, but there\u2019s yet another important factor to consider.<\/p><blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><em>In 2019, the dominant costs of processing scripts are now download and CPU execution time.<\/em><\/p><cite><a href=\"https:\/\/v8.dev\/blog\/cost-of-javascript-2019\">The Cost of JavaScript in 2019<\/a><\/cite><\/blockquote><p>JavaScript takes up a lot of CPU resources to execute. Even if you optimize third-party scripts to reduce the impact on rendering time, they can still affect the <a href=\"https:\/\/wp-rocket.me\/lighthouse-performance-score-wordpress\/improve-time-to-interactive\/\">Time to Interactive metric<\/a>. It measures how quickly users can interact with a webpage. The slower it is, the more frustrated your users will be and the higher the chances of them abandoning your website.<br><\/p><p>You can sum up the cost of using JavaScript with two main metrics.<\/p><h3 class=\"wp-block-heading\">Increased Page Size<\/h3><p>Byte-for-byte, JavaScript is <a href=\"https:\/\/httparchive.org\/reports\/page-weight\">the most expensive third-party resource<\/a> served by webpages. Since a browser needs to download all the linked third-party scripts during page load, adding them to your website can slow it down noticeably.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"492\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-JavaScript-Size-on-Webpages-HTTPArchive.png\" alt=\"The sum transfer size of external scripts on a webpage\" class=\"wp-image-2235025\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-JavaScript-Size-on-Webpages-HTTPArchive.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-JavaScript-Size-on-Webpages-HTTPArchive-310x191.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-JavaScript-Size-on-Webpages-HTTPArchive-768x472.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>The sum transfer size of external scripts on a webpage (Source: <a href=\"https:\/\/httparchive.org\/reports\/state-of-javascript\">HTTPArchive<\/a>)<\/figcaption><\/figure><p>The bigger the size of the scripts, the harder the fall will be of your website\u2019s performance. After all, the bigger the size of a web page, the slower it\u2019ll load.<br><\/p><p>Reducing the size of external scripts is an impressive way to speed up your website.<\/p><h3 class=\"wp-block-heading\">Additional Network Requests<\/h3><p>Every time a user requests any of your site\u2019s pages, the browser has to retrieve all the embedded third-party scripts. To do this, the browser will reach out to all the external URLs where these scripts are hosted to download them.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"492\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-HTTPS-Requests-on-Webpages-HTTPArchive.png\" alt=\"The number of external scripts requested by a typical page\" class=\"wp-image-2235035\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-HTTPS-Requests-on-Webpages-HTTPArchive.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-HTTPS-Requests-on-Webpages-HTTPArchive-310x191.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Median-HTTPS-Requests-on-Webpages-HTTPArchive-768x472.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>The number of external scripts requested by a typical page (Source: <a href=\"https:\/\/httparchive.org\/reports\/state-of-javascript\">HTTPArchive<\/a>)<\/figcaption><\/figure><p>Typically, each third-party script by itself doesn\u2019t amount to much. But loading <a href=\"https:\/\/wp-rocket.me\/blog\/reduce-http-requests-speed-wordpress-site\/\">every third-party script is an extra HTTP request<\/a> that the browser has to make to fully render the page. These requests pile up to slow down the page performance.&nbsp;<br><\/p><p>Also, the more requests your webpage has, the longer its \u2018Time to Interactive\u2019 metric will be.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"509\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Buzzfeed-Chrome-Developers-Tools-Network-Tab.png\" alt=\"Chrome DevTools shows a website making 846 requests and transferring 12.3 MB (April 2020)\" class=\"wp-image-2235096\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Buzzfeed-Chrome-Developers-Tools-Network-Tab.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Buzzfeed-Chrome-Developers-Tools-Network-Tab-300x191.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Buzzfeed-Chrome-Developers-Tools-Network-Tab-768x489.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Chrome DevTools shows a website making 846 requests and transferring 12.3 MB (April 2020)<\/figcaption><\/figure><p>In the above example, you can see that the page takes over 9 seconds to load completely. The primary culprit here is embedding a lot of third-party scripts that drag down the page load speed.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"468\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Percent-of-Request-by-Category-and-Content.png\" alt=\"Third-party requests by category and content type\" class=\"wp-image-2235109\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Percent-of-Request-by-Category-and-Content.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Percent-of-Request-by-Category-and-Content-300x176.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Percent-of-Request-by-Category-and-Content-768x449.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Third-party requests by category and content type (Source: <a href=\"https:\/\/almanac.httparchive.org\/en\/2019\/third-parties#fig-5\">Web Almanac<\/a>)<\/figcaption><\/figure><p>Scripts aren\u2019t the only third-party resources used by websites, but they make up a bulk of third-party requests across all categories and content types. Hence, optimizing them should be your priority.<\/p><h2 class=\"wp-block-heading\">Measuring the Impact of Loading Third-Party JavaScript<\/h2><p>There are many web page speed test tools you can use to diagnose third-party scripts and find out which of them are the costliest resources on your website. These tools show you the number of third-party scripts loaded by your site and the time they take to execute.<\/p><p>Here are a few free tools you can use to evaluate third-party scripts:<\/p><ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.webpagetest.org\/\">WebPageTest.org<\/a><\/li><li><a href=\"https:\/\/developer.chrome.com\/devtools\">Chrome DevTools<\/a><\/li><li><a href=\"https:\/\/developers.google.com\/speed\/pagespeed\/insights\">PageSpeed Insights<\/a> (Lighthouse Audits)<\/li><\/ul><h3 class=\"wp-block-heading\">WebPageTest.org<\/h3><p>WebPageTest is a free, open-source speed test tool that you can use to evaluate your website\u2019s performance. It includes many advanced features such as waterfall charts, content breakdown by type and domain, webpage rendering filmstrips and videos, and tests comparison.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"560\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-org-Speed-Testing-Tool.png\" alt=\"WebPageTest provides a lot of advanced tools to test your site\u2019s performance\" class=\"wp-image-2235115\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-org-Speed-Testing-Tool.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-org-Speed-Testing-Tool-279x195.png 279w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-org-Speed-Testing-Tool-768x538.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>WebPageTest provides a lot of advanced tools to test your site\u2019s performance<\/figcaption><\/figure><p>I tested my portfolio website on WebPageTest. Below is the waterfall view of the requests made by my site during its page load. That\u2019s a lot of requests, but not all are from third-party sources.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"958\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/salmanravoof.com-Waterfall-WebPageTest.png\" alt=\"Waterfall view of all the requests on WebPageTest\" class=\"wp-image-2235123\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/salmanravoof.com-Waterfall-WebPageTest.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/salmanravoof.com-Waterfall-WebPageTest-251x300.png 251w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/salmanravoof.com-Waterfall-WebPageTest-768x920.png 768w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/salmanravoof.com-Waterfall-WebPageTest-300x359.png 300w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Waterfall view of all the requests on WebPageTest<\/figcaption><\/figure><p>The waterfall chart breaks down requests by domain and size along with a timeline representing the page load.<br><\/p><p>You can also check out the content breakdown by type by clicking the \u2018Content Breakdown\u2019 tab. As you can see, JS makes up a lot of requests and bytes transferred.&nbsp;<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"476\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Type-WebPageTest.png\" alt=\"The number of JS requests and bytes transferred on WebPageTest\" class=\"wp-image-2235133\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Type-WebPageTest.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Type-WebPageTest-310x184.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Type-WebPageTest-768x457.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Check the number of JS requests and bytes transferred on WebPageTest<\/figcaption><\/figure><p>Clicking the \u2018Domains\u2019 tab will give you a full list of all the domains reached out by the browser during the page load.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"525\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Domains-WebPageTest.png\" alt=\"Content breakdown by domain on WebPageTest\" class=\"wp-image-2235143\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Domains-WebPageTest.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Domains-WebPageTest-297x195.png 297w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Content-Breakdown-by-Domains-WebPageTest-768x504.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Content breakdown by domain on WebPageTest<\/figcaption><\/figure><p>Here, most of the requests originate from the home domain itself. You can also click the \u2018Request Map\u2019 link to visualize all these requests.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"525\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Request-Map-Requests-WebPageTest.png\" alt=\"Visualize all the requests for loading a website on WebPageTest\" class=\"wp-image-2235151\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Request-Map-Requests-WebPageTest.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Request-Map-Requests-WebPageTest-297x195.png 297w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Request-Map-Requests-WebPageTest-768x504.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Visualize all the requests for loading a website on WebPageTest<\/figcaption><\/figure><p>If you recognize a problematic script that takes a lot of time to load or execute, check whether that script is necessary. Remove such scripts if they pose no perceivable harm to your website\u2019s functionality or user experience.<br><\/p><p>WebPageTest also provides a way for you to test your website\u2019s speed by <a href=\"https:\/\/sites.google.com\/a\/webpagetest.org\/docs\/using-webpagetest\/scripting#TOC-blockDomainsExecpt\">blocking requests originating from specific domains<\/a>. This is useful for measuring the performance impact of troublesome third-party scripts by targeting them specifically.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"519\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Advanced-Script-Tab-Block-Domains.png\" alt=\"WebPageTest scripting allows you to block requests from specific domains\" class=\"wp-image-2235159\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Advanced-Script-Tab-Block-Domains.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Advanced-Script-Tab-Block-Domains-300x195.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Advanced-Script-Tab-Block-Domains-768x498.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>WebPageTest scripting allows you to block requests from specific domains<\/figcaption><\/figure><pre class=\"wp-block-code\"><code class=\"\">blockDomainsExcept www.domain.com cdn.domain.com cdnjs.cloudflare.com\nnavigate  https:\/\/www.domain.com<\/code><\/pre><p>For example, you can block requests from all external domains (except important CDNs) and then direct WebPageTest to navigate to the site to test it.<br><\/p><p><strong>Note:<\/strong> You can also use the \u2018Block\u2019 tab in WebPageTest\u2019s \u2018Advanced Settings\u2019 section to do the same.<br><\/p><p>Here\u2019s a typical workflow to use WebPageTest to identify slow scripts:<\/p><ul class=\"wp-block-list\"><li>Test the original webpage.<\/li><li>Test the same webpage again, but this time with certain third-party scripts blocked.<\/li><li>Compare the two results using WebPageTest\u2019s \u2018Compare\u2019 feature from its \u2018Test History\u2019 panel.<\/li><\/ul><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"211\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Test-History-Compare-Results.png\" alt=\"Go to \u2018Test History\u2019 panel to compare two or more tests in WebPageTest\" class=\"wp-image-2235170\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Test-History-Compare-Results.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Test-History-Compare-Results-310x82.png 310w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WebPageTest-Test-History-Compare-Results-768x203.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Go to \u2018Test History\u2019 panel to compare two or more tests in WebPageTest<\/figcaption><\/figure><p>That isn\u2019t all that WebPageTest does. You can <a href=\"https:\/\/andydavies.me\/blog\/2018\/02\/19\/using-webpagetest-to-measure-the-impact-of-3rd-party-tags\/\">learn more about how you can use WebPageTest<\/a> to test the performance impact of third-party scripts.<\/p><h3 class=\"wp-block-heading\">Chrome DevTools&nbsp;<\/h3><p>Chrome DevTools supports <a href=\"https:\/\/developers.google.com\/web\/updates\/2017\/05\/devtools-release-notes#badges\">highlighting network requests by third-parties<\/a> in its \u2018Network\u2019 panel. This feature allows you to get detailed insights into third-party script requests on a page.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"162\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Third-Party-Badges-Tagging.png\" alt=\"Use the \u2018third party badges\u2019 tag to highlight external requests\" class=\"wp-image-2235177\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Third-Party-Badges-Tagging.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Third-Party-Badges-Tagging-300x61.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Third-Party-Badges-Tagging-768x156.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Use the \u2018third party badges\u2019 tag to highlight external requests (Source: <a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/optimizing-content-efficiency\/loading-third-party-javascript\">Google<\/a>)<\/figcaption><\/figure><p>To use this feature, press <strong>CTRL\/CMD + Shift + P<\/strong> in any of the Chrome DevTools panels to bring up the \u2018Command Menu\u2019. Next, type in \u201cShow third party badges\u201d and enable this feature.<\/p><figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Network-Badges-1.png\" alt=\"Hovering over a third-party script in Chrome DevTools\" class=\"wp-image-2235187\" width=\"580\" height=\"303\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Network-Badges-1.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Network-Badges-1-300x157.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-DevTools-Network-Badges-1-768x401.png 768w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><figcaption>Hovering over a third-party script in Chrome DevTools (Source: <a href=\"https:\/\/developers.google.com\/web\/updates\/2017\/05\/devtools-release-notes#badges\">Google<\/a>)<\/figcaption><\/figure><p><strong>Note:<\/strong> Google Chrome version 80 has <a href=\"https:\/\/support.google.com\/chrome\/thread\/29103162?hl=en\">removed this feature announcing no replacement<\/a>. It\u2019s most probably a bug. For now, you must sort external scripts manually until Google addresses this issue.<br><\/p><p>You can also use the <a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\/evaluate-performance\/reference\">\u2018Performance\u2019 panel<\/a> in Chrome DevTools to identify any performance issues on your website.&nbsp;<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"519\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Testing-Performance-Using-Chrome-DevTools-Performance-Tab.png\" alt=\"The \u2018Performance\u2019 panel in Chrome DevTools\" class=\"wp-image-2235192\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Testing-Performance-Using-Chrome-DevTools-Performance-Tab.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Testing-Performance-Using-Chrome-DevTools-Performance-Tab-300x195.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Testing-Performance-Using-Chrome-DevTools-Performance-Tab-768x498.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>The \u2018Performance\u2019 panel in Chrome DevTools<\/figcaption><\/figure><p>To learn more about how to test page load performance with Chrome DevTools, check out <a href=\"https:\/\/developers.google.com\/web\/tools\/chrome-devtools\/evaluate-performance\">Google\u2019s tutorial on this topic<\/a>.<\/p><h3 class=\"wp-block-heading\">Lighthouse Audits<\/h3><p>Google\u2019s Lighthouse speed test tool has two specific audits to evaluate your site\u2019s performance.<br><\/p><p>Lighthouse\u2019s <a href=\"https:\/\/developers.google.com\/web\/tools\/lighthouse\/audits\/bootup\">JavaScript boot-up time audit<\/a> ranks scripts by their parsing, compiling, and evaluation time. These metrics can help you discover third-party scripts that hog a lot of your server\u2019s resources.<\/p><figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-JavaScript-Boot-up-Time-Audit.png\" alt=\"Lighthouse \u2018JavaScript Boot-up Time\u2019 audit\" class=\"wp-image-2235197\" width=\"580\" height=\"379\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-JavaScript-Boot-up-Time-Audit.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-JavaScript-Boot-up-Time-Audit-300x196.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-JavaScript-Boot-up-Time-Audit-768x502.png 768w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><figcaption>Lighthouse \u2018JavaScript Boot-up Time\u2019 audit (Source: <a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/optimizing-content-efficiency\/loading-third-party-javascript\">Google<\/a>)<\/figcaption><\/figure><p>Lighthouse\u2019s <a href=\"https:\/\/developers.google.com\/web\/tools\/lighthouse\/audits\/network-payloads\">Network payloads audit<\/a> lists all the scripts by their total size and transfer time. You can use these metrics to identify third-party scripts that may slow down your site\u2019s page load time.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"477\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-Network-Payloads-Audit.png\" alt=\"Lighthouse \u2018Network Payloads\u2019 audit\" class=\"wp-image-2235202\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-Network-Payloads-Audit.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-Network-Payloads-Audit-300x179.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Lighthouse-Network-Payloads-Audit-768x458.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Lighthouse \u2018Network Payloads\u2019 audit (Source: <a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/optimizing-content-efficiency\/loading-third-party-javascript\">Google<\/a>)<\/figcaption><\/figure><p>Chrome\u2019s built-in Lighthouse tool also shows you costly third-party resources on a page ordered by their transfer size and time.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"639\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-Lighthouse-Third-Party-Usage-Feature.png\" alt=\"Addy Osmani's tweet on Lighthouse showing costly third-party resources\" class=\"wp-image-2235209\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-Lighthouse-Third-Party-Usage-Feature.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-Lighthouse-Third-Party-Usage-Feature-300x240.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Chrome-Lighthouse-Third-Party-Usage-Feature-768x613.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>(Source: <a href=\"https:\/\/twitter.com\/addyosmani\/status\/1156451928349372417?lang=en\">Addy Osmani<\/a>, Engineering Manager, Google Chrome Team)<\/figcaption><\/figure><p>Now that you\u2019ve learned how to test the performance of third-party scripts, it\u2019s time to learn how to reduce or nullify their harm.<\/p><div id=\"om-ulrdquoprwqcywqbbgci-holder\"><\/div>\n\t<script>(function (d, u, ac) {\n\t\t\tvar s = d.createElement('script')\n\t\t\ts.type = 'text\/javascript'\n\t\t\ts.src = 'https:\/\/a.omappapi.com\/app\/js\/api.min.js'\n\t\t\ts.async = true\n\t\t\ts.dataset.user = u\n\t\t\ts.dataset.campaign = ac\n\t\t\td.getElementsByTagName('head')[0].appendChild(s)\n\t\t})(document, 20440, 'ulrdquoprwqcywqbbgci')<\/script><h2 class=\"wp-block-heading\">How to Minimize the Effects of Third-Party Scripts on WordPress<\/h2><h3 class=\"wp-block-heading\">1. Delay the Loading of Third-Party Scripts<\/h3><p>If you find any third-party scripts slowing down your website, you can load them using HTML\u2019s <strong>async<\/strong> or <strong>defer<\/strong> attributes to avoid their negative impact on your page load.<br><\/p><p>The <strong>async<\/strong> attribute forces the browser to continue parsing the rest of the HTML document till the script gets downloaded. Once the script finishes downloading, it pauses parsing the HTML document to run the script.<br><\/p><p>The <strong>defer<\/strong> attribute does the same, except the browser doesn\u2019t run the script until it has parsed the entire HTML document.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"342\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/async-vs-defer-growingwiththeweb.png\" alt=\"\u2018async\u2019 vs \u2018defer\u2019 attributes \" class=\"wp-image-2235217\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/async-vs-defer-growingwiththeweb.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/async-vs-defer-growingwiththeweb-300x128.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/async-vs-defer-growingwiththeweb-768x328.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>\u2018async\u2019 vs \u2018defer\u2019 attributes (Source: <a href=\"https:\/\/www.growingwiththeweb.com\/2014\/02\/async-vs-defer-attributes.html\">Growing with the web<\/a>)<\/figcaption><\/figure><p>It\u2019s recommended to load all your third-party scripts with either <strong>async<\/strong> or <strong>defer<\/strong> attributes (unless they\u2019re crucial for your webpage\u2019s critical rendering path).&nbsp;<\/p><p>You can learn more about <a href=\"https:\/\/wp-rocket.me\/blog\/deferred-loading-of-javascript\/\">delaying JavaScript in WP Rocket\u2019s in-depth article<\/a>.<\/p><p><a href=\"https:\/\/wp-rocket.me\/features\/?utm_source=blog&amp;utm_medium=organic&amp;utm_campaign=blog-middle-cta-3&amp;utm_content=third-party\">WP Rocket is the easiest way to delay JavaScript files and let your page load faster.<\/a><\/p><h3 class=\"wp-block-heading\">2. Self-Host Third-Party JavaScript Files<\/h3><p>Hosting third-party scripts on your server can give you more control over how they\u2019re loaded. It helps <a href=\"https:\/\/wp-rocket.me\/blog\/how-to-reduce-dns-lookups-to-speed-up-your-wordpress-site\/\">reduce DNS lookup<\/a> and round-trip times, improve <a href=\"https:\/\/wp-rocket.me\/blog\/cache-control-http-headers\/\">HTTP caching headers<\/a>, and use advanced features such as <a href=\"https:\/\/docs.wp-rocket.me\/article\/1009-configuration-for-http-2\">HTTP\/2 server push<\/a>.<br><\/p><p>Self-hosting is recommended for any third-party scripts critical to your website\u2019s functioning (e.g. jQuery, Modernizr, Underscore.js).<br><\/p><p><strong>Warning:<\/strong> Self-hosted scripts can go out of date and not work as intended. For example, if you\u2019re self-hosting an ad serving script and if the ad publisher changes how their script works, then your website will not serve any ads till you update your self-hosted script manually.<\/p><h3 class=\"wp-block-heading\">3. Remove the Third-Party Script Altogether<\/h3><p>If a third-party script doesn\u2019t add any clear value to your site or users, then consider removing it. Many WordPress themes and plugins load a lot of unnecessary scripts that you may never use.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"94\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WordPress-jQuery-Migrate-Script.jpg\" alt=\"WordPress forces jQuery Migrate script to load \" class=\"wp-image-2235223\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WordPress-jQuery-Migrate-Script.jpg 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WordPress-jQuery-Migrate-Script-300x35.jpg 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/WordPress-jQuery-Migrate-Script-768x90.jpg 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>WordPress forces jQuery Migrate script to load <\/figcaption><\/figure><p>Even WordPress forces every site to load the jQuery Migrate script (<strong>wp-includes\/js\/jquery\/jquery-migrate.min.js<\/strong>). This helps older plugins and themes maintain backward compatibility with the old version of jQuery. While this isn\u2019t a third-party script as it\u2019s self-hosted, it still adds an extra HTTP request unnecessarily.&nbsp;<br><\/p><p><strong>Tip:<\/strong> You can use WP Rocket\u2019s built-in options to <a href=\"https:\/\/docs.wp-rocket.me\/article\/1304-remove-jquery-migrate\">remove the jQuery Migrate script<\/a> from loading.&nbsp;<br><\/p><p>Ask yourself whether your website really needs a slider or a date formatting script. If you\u2019re not sure, you can <a href=\"https:\/\/wp-rocket.me\/blog\/how-to-use-a-b-testing\/\">perform A\/B testing<\/a> to check if removing a script impacts your website\u2019s performance vs usability.<\/p><h3 class=\"wp-block-heading\">4. Implement Browser Resource Hints<\/h3><p>Connecting to external domains to download third-party scripts can take an excessive amount of time, especially if your users are on slow networks. DNS lookups, redirects, and any round-trips for loading each third-party script can add up to significant delays.&nbsp;<br><\/p><p>You can use browser resource hints to establish a connection with the external domain hosting the third-party script at the start of page load itself.&nbsp;<br><\/p><p>There are many resource hints, but the ones that are helpful here are <strong>dns-prefetch<\/strong> or <strong>preconnect<\/strong>.<\/p><pre class=\"wp-block-code\"><code class=\"\">&lt;link rel=\"dns-prefetch\" href=\"http:\/\/domain.com\"&gt;<\/code><\/pre><p>If the ultimate destination of your third-party script\u2019s external domain uses <strong>https:\/\/<\/strong>, then you can use it to avoid TCP round-trips and handle any TLS negotiations beforehand.<\/p><pre class=\"wp-block-code\"><code class=\"\">&lt;link rel=\"preconnect\" href=\"https:\/\/cdn.domain.com\"&gt;<\/code><\/pre><p><br>For more, check out <a href=\"https:\/\/wp-rocket.me\/blog\/preload-prefetch-preconnect-speed-site-browser-resource-hints\/\">WP Rocket\u2019s article on browser resource hints<\/a>.<\/p><h3 class=\"wp-block-heading\">5. Lazy-load Third-Party JavaScript<\/h3><p>Embedded third-party elements such as ads and videos add a lot of stress on your website, more so if they\u2019re delivered via poorly optimized sources. You can lazy-load these embedded resources to speed up your page load.<br><\/p><p>For instance, if you\u2019re serving ads in the footer of your website, you can lazy-load them so that they\u2019re only loaded when the user scrolls down the page.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"355\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/LazyLoad-Third-Party-Scripts.png\" alt=\"Lazy-loading below-the-fold content \" class=\"wp-image-2235232\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/LazyLoad-Third-Party-Scripts.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/LazyLoad-Third-Party-Scripts-300x133.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/LazyLoad-Third-Party-Scripts-768x341.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>Lazy-loading below-the-fold content (Source: <a href=\"https:\/\/developers.google.com\/web\/fundamentals\/performance\/optimizing-content-efficiency\/loading-third-party-javascript\">Google<\/a>)<\/figcaption><\/figure><p>You can use WP Rocket to <a href=\"https:\/\/wp-rocket.me\/blog\/lazy-loading-wordpress-5-5\/\">enable lazy-loading on your WordPress website<\/a>.&nbsp;<br><\/p><p><strong>Note:<\/strong> <a href=\"https:\/\/wp-rocket.me\/blog\/lazy-loading-wordpress-5-5\/\">WordPress 5.5 added native lazy-loading<\/a> functionality, making this a default feature for millions of websites.<br><\/p><p>If you\u2019re embedding ads on your website, <a href=\"https:\/\/www.mediavine.com\/lazy-loading-ads-mediavine-ads-load-200-faster\/\">check out this article by Mediavine<\/a> where they discuss how they improved their page speed by 200% after implementing lazy-loading.<\/p><h3 class=\"wp-block-heading\">Use a Tag Manager to Organize Third-Party JS<\/h3><p>Tag managers allow you to bundle multiple third-party scripts (or tags) and manage them all from a single source. Using a tag manager wisely can help you <a href=\"https:\/\/wp-rocket.me\/blog\/how-third-party-tags-and-trackers-impact-website-performance\/\">minimize the performance hits of loading third-party scripts<\/a>.<br><\/p><p>While you can load third-party scripts asynchronously, the browser still needs to parse and execute them individually. This might mean requesting additional data during the page load. Tag managers solve this problem by reducing the number of requests down to one.<br><\/p><p><a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager<\/a> (GTM) is the most popular solution to manage tags. It loads itself and all its tags asynchronously so that the browser renders a page without pause. Even a slow loading third-party script won\u2019t block any other script from being loaded.<\/p><p>The <a href=\"https:\/\/wordpress.org\/plugins\/duracelltomi-google-tag-manager\/\">Google Tag Manager for WordPress<\/a> plugin is a simple way to integrate GTM on WordPress sites.&nbsp;<br><\/p><p>Other tag managers that you can look into are <a href=\"https:\/\/www.adobe.com\/experience-platform\/launch.html\">Adobe Experience Platform Launch<\/a>, <a href=\"https:\/\/www.ensighten.com\/\">Ensighten<\/a>, and <a href=\"https:\/\/www.qubit.com\/\">Qubit<\/a>.<br><\/p><p><strong>Warning:<\/strong> Use tag managers like GTM judiciously. While it reduces the cost of loading third-party scripts, its simplicity also opens it to abuse by anyone with the credentials to add tags. Some tags can also introduce a chain of requests that can bring your site to a crawl.<\/p><figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"569\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Website-on-Tag-Managers-and-Without.png\" alt=\"Harry Roberts's tweet on tag managers\" class=\"wp-image-2235322\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Website-on-Tag-Managers-and-Without.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Website-on-Tag-Managers-and-Without-300x213.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Website-on-Tag-Managers-and-Without-768x546.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><figcaption>(Source: <a href=\"https:\/\/twitter.com\/csswizardry\/status\/915886339391918083\">Harry Roberts<\/a>, Consultant Performance Engineer at Google, BBC, Kickstarter, etc.)<\/figcaption><\/figure><h3 class=\"wp-block-heading\">Have a Performance Budget<\/h3><p>Once you\u2019ve optimized your site\u2019s performance, you need to use a <em>performance budget<\/em> to ensure that your site\u2019s performance doesn\u2019t regress over time.&nbsp;<br><\/p><p>A <em>performance budget<\/em> is a self-imposed limit to count the total number of requests and size of scripts, images, etc. It can also include setting a limit for performance metrics such as \u2018Time to Interactive\u2019 and \u2018First Meaningful Paint\u2019.&nbsp;<br><\/p><p>For more, check out the <a href=\"https:\/\/github.com\/GoogleChrome\/lighthouse\/blob\/master\/docs\/performance-budgets.md\">list of all the supported resource types and metrics<\/a>.<\/p><figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Set-Performance-Budget-Lighthouse.png\" alt=\"Lighthouse will flag pages that exceed the performance budget \" class=\"wp-image-2235330\" width=\"580\" height=\"201\" srcset=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Set-Performance-Budget-Lighthouse.png 800w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Set-Performance-Budget-Lighthouse-300x104.png 300w, https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/Set-Performance-Budget-Lighthouse-768x267.png 768w\" sizes=\"(max-width: 580px) 100vw, 580px\" \/><figcaption>Lighthouse will flag pages that exceed the performance budget (Source: <a href=\"https:\/\/developers.google.com\/web\/tools\/lighthouse\/audits\/budgets\">Google<\/a>)<\/figcaption><\/figure><p>You can use Lighthouse\u2019s <strong>Keep Request Counts Low And File Sizes Small<\/strong> audit to set your performance budget. Discussing the exact method to set performance budgets is beyond the scope of this article, but you can <a href=\"https:\/\/developers.google.com\/web\/tools\/lighthouse\/audits\/budgets\">read more about how to do it<\/a> in Lighthouse docs.<\/p><h2 class=\"wp-block-heading\">Wrapping Up<\/h2><p>Third-party scripts have become a crucial part of most websites today. Even if you\u2019ve optimized all the other code on your website, you cannot control how third-party scripts play out. You cannot avoid them either as some of them may be critical to your site\u2019s functionality, user experience, or revenue stream.<br><\/p><p>Some topics discussed in this article may not be easy to grasp right away. I suggest you go through them once again. Understanding the performance impact of third-party scripts and how you can manage them will help you regain control over your page load performance.<\/p><p>WP Rocket can easily help you reduce the impact of third-party code. <a href=\"https:\/\/wp-rocket.me\/features\/?utm_source=blog&amp;utm_medium=organic&amp;utm_campaign=blog-final-cta-4&amp;utm_content=third-party\">Get it now, and test the improvement right away!<\/a><br><\/p><p><em>If you have questions about any of the points discussed in this article, please feel free to leave a comment.<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>Third-party scripts are one of the leading causes of performance slowdowns on websites. They\u2019re usually the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.<\/p>\n","protected":false},"author":131875,"featured_media":2235631,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"kia_subtitle":"","footnotes":""},"categories":[63],"tags":[],"class_list":["post-2234894","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress-cache"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>5 Proven Ways to Reduce the Impact of Third-Party Code on WordPress<\/title>\n<meta name=\"description\" content=\"Third-party scripts are the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"5 Proven Ways to Reduce the Impact of Third-Party Code on WordPress\" \/>\n<meta property=\"og:description\" content=\"Third-party scripts are the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Rocket\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-05T09:05:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-12T13:37:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"460\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Salman Ravoof\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:site\" content=\"@wp_rocket\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Salman Ravoof\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"18 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\"},\"author\":{\"name\":\"Salman Ravoof\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/0152a367f602a6628c0bc4ecace1fc34\"},\"headline\":\"How to Reduce the Impact of Third-Party Scripts on WordPress\",\"datePublished\":\"2020-05-05T09:05:00+00:00\",\"dateModified\":\"2024-09-12T13:37:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\"},\"wordCount\":2904,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png\",\"articleSection\":[\"Page speed and caching\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\",\"url\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\",\"name\":\"5 Proven Ways to Reduce the Impact of Third-Party Code on WordPress\",\"isPartOf\":{\"@id\":\"https:\/\/wp-rocket.me\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png\",\"datePublished\":\"2020-05-05T09:05:00+00:00\",\"dateModified\":\"2024-09-12T13:37:03+00:00\",\"description\":\"Third-party scripts are the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.\",\"breadcrumb\":{\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png\",\"width\":1100,\"height\":460,\"caption\":\"Third-party scripts performance\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wp-rocket.me\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Page speed and caching\",\"item\":\"https:\/\/wp-rocket.me\/blog\/wordpress-cache\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Reduce the Impact of Third-Party Scripts on WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wp-rocket.me\/#website\",\"url\":\"https:\/\/wp-rocket.me\/\",\"name\":\"WP Rocket\",\"description\":\"Plugin d&#039;optimisation de sites WordPress\",\"publisher\":{\"@id\":\"https:\/\/wp-rocket.me\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wp-rocket.me\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/wp-rocket.me\/#organization\",\"name\":\"WP Rocket\",\"url\":\"https:\/\/wp-rocket.me\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"contentUrl\":\"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png\",\"width\":150,\"height\":41,\"caption\":\"WP Rocket\"},\"image\":{\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829\",\"https:\/\/x.com\/wp_rocket\",\"https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/0152a367f602a6628c0bc4ecace1fc34\",\"name\":\"Salman Ravoof\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wp-rocket.me\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2250657129436509050f973d3042ddd7?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2250657129436509050f973d3042ddd7?s=96&d=mm&r=g\",\"caption\":\"Salman Ravoof\"},\"description\":\"Salman Ravoof is a self-taught web developer, writer, and creator. He\u2019s a huge fan of Free and Open-Source Software. Apart from tech, he finds science, philosophy, and food exciting. Learn more about him on his website, and connect with Salman on Twitter.\",\"sameAs\":[\"https:\/\/wp-rocket.me\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"5 Proven Ways to Reduce the Impact of Third-Party Code on WordPress","description":"Third-party scripts are the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/","og_locale":"en_US","og_type":"article","og_title":"5 Proven Ways to Reduce the Impact of Third-Party Code on WordPress","og_description":"Third-party scripts are the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.","og_url":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/","og_site_name":"WP Rocket","article_publisher":"https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","article_published_time":"2020-05-05T09:05:00+00:00","article_modified_time":"2024-09-12T13:37:03+00:00","og_image":[{"width":1100,"height":460,"url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png","type":"image\/png"}],"author":"Salman Ravoof","twitter_card":"summary_large_image","twitter_creator":"@wp_rocket","twitter_site":"@wp_rocket","twitter_misc":{"Written by":"Salman Ravoof","Est. reading time":"18 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#article","isPartOf":{"@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/"},"author":{"name":"Salman Ravoof","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/0152a367f602a6628c0bc4ecace1fc34"},"headline":"How to Reduce the Impact of Third-Party Scripts on WordPress","datePublished":"2020-05-05T09:05:00+00:00","dateModified":"2024-09-12T13:37:03+00:00","mainEntityOfPage":{"@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/"},"wordCount":2904,"commentCount":2,"publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"image":{"@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png","articleSection":["Page speed and caching"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/","url":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/","name":"5 Proven Ways to Reduce the Impact of Third-Party Code on WordPress","isPartOf":{"@id":"https:\/\/wp-rocket.me\/#website"},"primaryImageOfPage":{"@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage"},"image":{"@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage"},"thumbnailUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png","datePublished":"2020-05-05T09:05:00+00:00","dateModified":"2024-09-12T13:37:03+00:00","description":"Third-party scripts are the costliest resource during page load. Learn why they affect website performance and how to mitigate their negative effects.","breadcrumb":{"@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wp-rocket.me\/blog\/third-party-scripts\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#primaryimage","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/third-party-scripts-performance.png","width":1100,"height":460,"caption":"Third-party scripts performance"},{"@type":"BreadcrumbList","@id":"https:\/\/wp-rocket.me\/blog\/third-party-scripts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wp-rocket.me"},{"@type":"ListItem","position":2,"name":"Page speed and caching","item":"https:\/\/wp-rocket.me\/blog\/wordpress-cache\/"},{"@type":"ListItem","position":3,"name":"How to Reduce the Impact of Third-Party Scripts on WordPress"}]},{"@type":"WebSite","@id":"https:\/\/wp-rocket.me\/#website","url":"https:\/\/wp-rocket.me\/","name":"WP Rocket","description":"Plugin d&#039;optimisation de sites WordPress","publisher":{"@id":"https:\/\/wp-rocket.me\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wp-rocket.me\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/wp-rocket.me\/#organization","name":"WP Rocket","url":"https:\/\/wp-rocket.me\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/","url":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","contentUrl":"https:\/\/wp-rocket.me\/wp-content\/uploads\/1\/logo-wp-rocket-paypal-2.png","width":150,"height":41,"caption":"WP Rocket"},"image":{"@id":"https:\/\/wp-rocket.me\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/pages\/WP-Rocket\/631942253526829","https:\/\/x.com\/wp_rocket","https:\/\/www.youtube.com\/channel\/UC1ozThXHd1IWIZ5wkshgp_Q"]},{"@type":"Person","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/0152a367f602a6628c0bc4ecace1fc34","name":"Salman Ravoof","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wp-rocket.me\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2250657129436509050f973d3042ddd7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2250657129436509050f973d3042ddd7?s=96&d=mm&r=g","caption":"Salman Ravoof"},"description":"Salman Ravoof is a self-taught web developer, writer, and creator. He\u2019s a huge fan of Free and Open-Source Software. Apart from tech, he finds science, philosophy, and food exciting. Learn more about him on his website, and connect with Salman on Twitter.","sameAs":["https:\/\/wp-rocket.me\/"]}]}},"_links":{"self":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts\/2234894"}],"collection":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/users\/131875"}],"replies":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/comments?post=2234894"}],"version-history":[{"count":0,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/posts\/2234894\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media\/2235631"}],"wp:attachment":[{"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/media?parent=2234894"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/categories?post=2234894"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp-rocket.me\/wp-json\/wp\/v2\/tags?post=2234894"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}