@connorjclark @patrickhulce
Following the discussion here https://github.com/GoogleChrome/lighthouse/issues/8698#issuecomment-526439044, I mentioned that the website I manage is penalised by Lighthouse for loading cookie consent script and third party scripts after window.onload.
Here's the current loading sequence:
window.onload is calledI got 40 lighthouse points for doing this, which I think is probably the most efficient way to load third party scripts as pointed out by Addy Osmani's talk.
I did some test with the load event listener and without. Surprisingly, loading those stuff before load gave better results. But this is less efficient because third party scripts are blocking my codesplit js bundles.
I think Lighthouse should handle this better. Perhaps give less weight or ignore scripts loaded after the window.onload event. Happy to discuss this further.
Thanks for filing @pxwee5!
tl;dr - we are working on a few new metrics that will improve things a little for this page, but we will not start ignoring the impact of late tasks. The real wins left here require reducing total execution time, not re-ordering anything.
IIUC, the root of your concern here is that you've followed the advice given to you but the score isn't very good. The remaining advice left to follow is to break up CPU work and reduce overall execution time. A few more specific thoughts on that:
Hope this helps!
Understood. My JS execution time isn't great due to the fact that I'm relying on Javascript to parse a PHP rendered HTML page, which is a limitation that I inherited. This creates the biggest JS parsing/execution chunk (800ms), which is unlikely to be broken up. However, this will be fixed later when we implement SSR.
Fact is code-splitting has allowed me to break up my entire bundle which allowed for better performance. I'm just super surprised that I am badly penalised in Lighthouse for loading some of those scripts after window.load (late tasks). But these are quick to parse/execute so I have no issues with them loading late. I understand that I'm loading some heavy JS here it could block user input and these definitely should impact Lighthouse score.
Hopefully the new metrics that you've mentioned can help with the score a little bit.
Most helpful comment
Thanks for filing @pxwee5!
tl;dr - we are working on a few new metrics that will improve things a little for this page, but we will not start ignoring the impact of late tasks. The real wins left here require reducing total execution time, not re-ordering anything.
IIUC, the root of your concern here is that you've followed the advice given to you but the score isn't very good. The remaining advice left to follow is to break up CPU work and reduce overall execution time. A few more specific thoughts on that:
Hope this helps!