Home » Blogs » Reduce the Impact of Third Party Code

Reduce the Impact of Third Party Code in Magento 2

A third-party script is defined as any script hosted on a domain that’s different from the domain of the current URL so even if you serve assets from an alternative domain that you manage yourself, such as cdn.mysite.com, it will still be treated as the third party.

1. Identification

Tools like GT Metrix, Lighthouse, Page speed insights
Reduce-the-impact-of-third-party-code-mobile

2. How to Block Scripts:Network Request Blocking

In the Chrome Dev Tool,
Go to Network > JS > Right click on a script > Block request URL.
Network-Request-Blocking

3. Improving Load Times for Third-Party JavaScript

se defer and async attributes
Async instructs browsers to execute the JavaScript as soon as it has finished downloading the code. Defer instructs a browser to wait until all HTML parsing is complete before executing the downloaded JavaScript.

4. How to remove third-party script Third-party script

Example:
Visual website optimizer first
Find the script and remove it from there: Admin setting,
Content > Design > Configuration > Action > Edit > HTML head > Scripts and Stylesheets > Check
Visual-website-optimizer-first

Leave A Comment