Handling external resources

This article was built as a guide on how the external content affects the performance of a site, and how site owners can handle them.

The problem with external content

Every website contains images, CSS and JavaScript files  to create a pleasant and effective user experience.

These files, also known as resources, can be hosted in one of two ways:

  • Internal resources are stored on your website's own domain
  • External resources are not stored on your domain, but from third-party locations (e.g. Google, Facebook, Ad networks).

Externally hosted resources often impact the performance of your website significantly:

  • They require additional DNS resolutions for each external domain used, which adds extra time.
  • Some optimizations like browser caching and GZIP compression can only be applied to files hosted on your server. You cannot control resources that are hosted on other servers. 
  • In the case of external JavaScript, like ad scripts and social media scripts, these often introduce chains of other files loaded onto your site that you cannot control. These can be the most problematic for performance.

The more external resources loaded on your site, the greater the chance that your website will load slowly. 

How can WP Rocket help?

It's not possible for WP Rocket to optimize every external resource completely, but the following features can help:

Minify and Combine JavaScript

JavaScript files hosted on external domains, will be processed by Minify/Combine JS settings. This means that the external files will be hosted on your own domain, minified, and if combine is active, included in the combined file. If you have enabled the CDN setting in WP Rocket, they will be served from your CDN. 

Minify CSS

CSS files hosted on external domains, will be processed by the Minify CSS setting. This means that the external files will be minified, and hosted on your own domain. If you have enabled the CDN setting in WP Rocket, they will be served from your CDN. 

Delay JavaScript Execution

Delaying the execution of external JavaScript will help reduce its negative performance impact.

Google Fonts

WP Rocket automatically applies the setting Optimize Google Fonts. While this does not host the fonts locally, it does improve the performance.
Read why we don't recommend hosting Google Fonts locally.

LazyLoad

Depending on exactly how they're included in the page, many externally hosted images will benefit from the LazyLoad feature. Videos and other external content loaded in iframes will benefit from the iframes LazyLoad option.

Browser caching and compression

The most common warnings from speed testing tools (PageSpeed, Pingdom, GT Metrix etc) related to external resources are for browser caching and compression (GZIP or Brotli). These are impossible to satisfy since you simply cannot apply those optimizations for files that do not live on your own server. Please see the following guides for more information about how WP Rocket applies these:

In the examples below, taken from the Techcrunch site, the recommendations are impossible to resolve. All the domains referenced are 3rd parties:

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.