You can usually identify the impact that third party scripts are having on your website loading times by using a tool such as Google PageSpeed or GT metrics.
In English, this means that a third party script will not impact the loading time of your website because it isn't downloaded automatically. Instead, the script will be downloaded on the website when a user scrolls or clicks.
This is different than defer because (noncritical) scripts simply are not loaded unless a user interacts with the page.
The back end of this plugin is extremely simple and easy to use. Once you've installed the script on your website (you can use the free code snippets plugin to do this), simply identify the third party script with a keyword in the Flying Scripts interface, and it will only be loaded on user interaction.
You can add as many keywords as you want. For example, this is the keyword for the Facebook Messenger live chat that can be installed in any website. “fbevents.js” Refers to the Facebook Pixel and “analytics.js” refers to Google Analytics.
It's really as simple as that.
Next up is a plugin called Perfmatters. This is a “Jack of all trades” speed optimization tool, but we're going to specifically use the feature that allows you to host Google Analytics scripts locally.
Hosting this script locally allows you to make less DNS requests. This reduces the impact of it on your website's loading time, and resolves the issue “leverage browser caching”.
All you need to do is toggle local analytics on, and then enter your tracking ID. There are a couple of other features regarding GA that you can ignore or use depending on your website requirements.
For example you can:
If you have any questions on how to optimize your WordPress website for speed, feel free to reach out in the comment section below.