publisher-ads-lighthouse-plugin icon indicating copy to clipboard operation
publisher-ads-lighthouse-plugin copied to clipboard

Audit wrongly interprets <link rel="preload"> as duplicate tag loading

Open oliverfernandez opened this issue 5 years ago • 2 comments

Site: https://mejorconsalud.com

You can see an audit example here

In order to balance Lighthouse for Ads and normal Lighthouse, GPT library is preloaded using <link rel=prefetch as=script href="https://securepubads.g.doubleclick.net/tag/js/gpt.js"/> which is later converted into <script src="https://securepubads.g.doubleclick.net/tag/js/gpt.js">

With this approach, Ligthouse for Ads yields 2 issues which we consider are not accurate

  1. Tags best practices - Load tags only once per frame Here I think that Ligthouse is wrongly detecting that GPT library is being loaded twice, and if you check the network panel in Dev tools it actually appears twice, but the first one is initiated by <link rel="prefetch"> and the second one by <script> but is coming from the cache

  2. Ad speed - Load ad scripts statically Again, it seems that Lighthouse is yielding this error because our approach of using first <link rel="preload"> and later converting it to <script> But we consider this a fair approach, in order to control the initial amount of Javascript being executed and to don't penalize the Time to Interactive, or First Input Delay.

In our case, we use this approach in order to prioritize the execution of the CMP over the GPT library, in order to retreive user content, which is mandatory in Europe before start loading ads.

oliverfernandez avatar Dec 09 '19 08:12 oliverfernandez

Thanks for raising this issue. We'll work on fixes.

For issue (1), I would expect the browser to issue only one request in your case since the request for script tag should hit the prefetch cache. But that doesn't appear to be happening here.

For some additional background on (2), we discussed similar issues in issue #128. I'll look into your site a bit further and propose a change soon.

warrengm avatar Dec 09 '19 14:12 warrengm

@warrengm Thanks! Please let me know if you need more information from my side

oliverfernandez avatar Dec 10 '19 08:12 oliverfernandez