In principle, it is almost impossible to solve this. If you check the document here .
Keep all third-party JavaScript out of the critical path
Third-party JS likes to use JS synchronous loading. They would also like document.write more synchronization scripts. For example, if you have five ads, and each of them performs three synchronization downloads, with a 1 second latent connection, you are in 18 seconds of loading time just to download JS.
AMP pages allow third-party JavaScript, but only in isolated iframes. By banning them in an iframe, they cannot block the execution of the main page. Even if they trigger multiple style recalculations, their tiny iframes have very little DOM.
Comparison of types and layouts is typical of the DOM size, so iframes are very fast compared to the styles and layout for the page.
source share