New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle scripts loaded after window.onload better. #9812
Comments
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 Hopefully the new metrics that you've mentioned can help with the score a little bit. |
@connorjclark @patrickhulce
Following the discussion here #8698 (comment), I mentioned that the website I manage is penalised by Lighthouse for loading cookie consent script and third party scripts after
window.onload
.What is the current behavior?
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.
What is the expected behavior?
I did some test with the
load
event listener and without. Surprisingly, loading those stuff beforeload
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.The text was updated successfully, but these errors were encountered: