A 3rd party script is a JavaScript resource loaded into a webpage to provide functionality beyond the core functionality of the website. 

Added content:

A third-party JavaScript refers to a script that is able to become embedded by a third-party vendor directly into any website. JavaScript makes the internet more interactive and dynamic and includes;

Ads

Widgets

Analytics 

Various other scripts

 

Third party scripts include;

Social sharing buttons such as Facebook, Twitter and G+

Video player embeds such as YouTube and Vimeo

Analytics and metrics scripts

Advertising iframes

Helper libraries such as date formatting, functional libraries and animation

Experimental A/B testing scripts

 

Embedding third-party scripts are a major cause of slowing down performance which is often due to resources for which you have no control. Many of these issues include;

Too many network requests being fired to multiple servers, resulting in longer loading times.

Too much JavaScript being sent, keeping the main thread busy, blocking DOM construction and slowing the speed at which pages can render. Also, CPU intensive script parsing and execution can cause a delay in user interaction, resulting in battery drain.

Large image files or videos that are unoptimized being sent that can eat up data at the expense of users.

A single-point of failure or an SPOF because of third party scripts carelessly being loaded.

Frequent resources being fetched often from the network due to insufficient HTTP caching.

A lack of sufficient server compression of resources.

As is in the case of async A/B testing scripts, where content display is blocked until processing is completed.

The use of legacy APIs such as document.write() which is known to harm the experience of the user.

Expensive CSS selectors or excessive DOM elements.

Using too many third party embeds can cause multiple frameworks and libraries to be pulled in several times, which is not only wasteful but worsens the performance issues.

Even where embeds are using async or defer in a third party script, they can block window.onload due to slow responding servers.

Reassuringly, there a numerous solutions and tools available that have the ability to detect and repair any issues you may have with third party resources. 

Identifying third-party script.

Unless you know which third-party scripts are being loaded by your website and their impact on performance, sadly, it is impossible to know how they can be optimized. There are lots of free website speed testing tools out there, such as, Chrome DevTools and WebPage Test. These helpful tools are able to highlight costly third-parties. They display valuable diagnostic information that shows the amount of third-party scripts being loaded and which of these are taking longer to execute.

When you discover a script that may be causing problems, work out what it is this script actually does and think about whether you actually need it or not. You can use A/B testing to work out whether its value is worth more than user experience or performance metrics.