Reduce the Impact of Third Party Code in Shopify
The performance of a website can be affected by third-party code. Whenever possible, limit the number of redundant third-party providers and load third-party code after your primary page has loaded.
1. Identification for reduce the impact of third party code
Tools like GT metrix,lighthouse,Page speed insights.
2. Block scripts
To estimate the potential improvement removing a script will have, Chrome allows specific scripts to be blocked for Lighthouse audits.
Go to Network > JS > right click on a script > Block request URL
3. Improving Load Times for Third-Party JavaScript
Use defer or async where you can
With async, the file gets downloaded asynchronously and then executed as soon as it’s downloaded. With defer, the file gets downloaded asynchronously, but executed only when the document parsing is completed. With defer, scripts will execute in the same order as they are called.
Example
i)< script defer src=”/js/jquery.min.js” >< /script >
ii)< script src=“https://t.adcell.com/js/trad.js” type=”text/javascript” defer >< /script >
iii)< script src=”{{‘lazysizes.min.js’|asset_url}}” async=”async” >< /script >