How can I optimize third-party scripts?
For less critical assets, such as analytics, you can use the dns-prefetch attribute for the link
If the script isn't required for the page to render, you can use dns-prefetch to get the browser to do the initial DNS setup:
<link rel="dns-prefetch" href="www.googletagmanager.com">
<link rel="dns-prefetch" href="www.google-analytics.com">