-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Prefetching resources degrades TBT score and over performance score #15351
Comments
Is it possible to see two version of the page, one with prefetch enabled and one with prefetch disabled? Or perhaps some other minimum repro case would work. This is possibly related to our Can you try enabling DevTools throttling and report the difference in page performance? |
The vast majority of our prefetches are to resources in the If not we could add a URL param that disables prefetching. Would that be good enough? My guesses:
|
Depending on how the resources are used this may have side-effects that dilute the results. I'll give it a try though.
This is an interesting point, however I would expect prefetch to make TTI shorter since the resources would be fetched near the beginning of the navigation rather than the end. |
Just blocking prefetch requests does reduce TTI and reduces TBT in my testing, however this is expected since we are removing the requests completely rather than removing their prefetch. @shappir in your original results, were you testing with the requests completely blocked or with prefetch disabled? |
This is prefetch, not preload. It is used to fill the cache with resources for the next navigation, not the current one. This is why it's done so late in load process.
Wholly disabled - we turned off the code that generated the prefetch links. I will create a URL param that completely disables prefetch and update you as soon as it's deployed. Hopefully later today. |
Sorry for the delay - I've been ill. We added a URL param that disables the prefetch mechanism:
Due to A/B tests occasionally the page may be redirected. This can impact the results so watch out for that. I've run PSI with and without the URL parameter and see a significant impact on TBT (mobile):
|
The TTI is somewhat worse when the prefetch links are included, but I don't think this can explain the large difference in TBT alone. FWIW I tested both urls using DevTools throttling and the results are similar: With Prefetch Perhaps something can be adjusted in our lantern simulations? |
This website is implemented using NextJS / React, which uses SSR. The prefetch is implemented on client-side only (not part of the SSR). The prefetch elements are added to the DOM by client-side script only. This script is triggered by Given this, for real-world sessions the prefetch mechanism should not have any impact on FCP. Yet in these LH recordings it does. (Note that in my PSI tests it doesn't.) The prefetch mechanism is intentionally implemented in this way and executed late in the page's load process precisely in order to precent adverse impact on load performance. |
FAQ
URL
https://www.nextinsurance.com/
What happened?
Prefetching resources increases TBT and lower performance score as measured by Lighthouse. Checked using PageSpeed Insights and local Lighthouse installation, and experienced consistent behavior in both cases. We repeatedly enabled and disabled the prefetch and saw the same behavior.
<link rel="prefetch" ...>
into the HTMLrequestIdleCallback
requestIdleCallback
again to continueGraph shows TBT improvement when prefetch was disabled
What did you expect?
No impact of late executing prefetch on TBT or overall score
Especially given that code never executes for more than 25ms and the continues after
requestIdleCallback
What have you tried?
How were you running Lighthouse?
node, PageSpeed Insights, Chrome DevTools
Lighthouse Version
10.3.0
Chrome Version
No response
Node Version
No response
OS
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: