PHP: How to Add Expire Headers for External Scripts

Every website is using external JavaScript files. They are required, for example, when using Google Analytics, or an ad provider like BuySellAds. In order to leverage browser caching and optimize your website speed, it is recommended that you add expire headers to your script, which you can’t do on external files. In this article, I’ll show you how to dynamically import external JavaScript files into your own website for better performance.

The Problem With External Scripts
When using an external service as such as Google Analytics, you are often required to include external JavaScript files into your own website.