(request: Request)
| 420 | const DEFAULT_PROGRESSIVE_CHUNK_SIZE = 12800; |
| 421 | |
| 422 | function getBlockingRenderMaxSize(request: Request): number { |
| 423 | // We want to make sure that we can block the reveal of a well designed complete |
| 424 | // shell but if you have constructed a too large shell (e.g. by not adding any |
| 425 | // Suspense boundaries) then that might take too long to render. We shouldn't |
| 426 | // punish users (or overzealous metrics tracking) in that scenario. |
| 427 | // There's a trade off here. If this limit is too low then you can't fit a |
| 428 | // reasonably well built UI within it without getting errors. If it's too high |
| 429 | // then things that accidentally fall below it might take too long to load. |
| 430 | // Web Vitals target 1.8 seconds for first paint and our goal to have the limit |
| 431 | // be fast enough to hit that. For this argument we assume that most external |
| 432 | // resources are already cached because it's a return visit, or inline styles. |
| 433 | // If it's not, then it's highly unlikely that any render blocking instructions |
| 434 | // we add has any impact what so ever on the paint. |
| 435 | // Assuming a first byte of about 600ms which is kind of bad but common with a |
| 436 | // decent static host. If it's longer e.g. due to dynamic rendering, then you |
| 437 | // are going to bound by dynamic production of the content and you're better off |
| 438 | // with Suspense boundaries anyway. This number doesn't matter much. Then you |
| 439 | // have about 1.2 seconds left for bandwidth. On 3G that gives you about 112.5kb |
| 440 | // worth of data. That's worth about 10x in terms of uncompressed bytes. Then we |
| 441 | // half that just to account for longer latency, slower bandwidth and CPU processing. |
| 442 | // Now we're down to about 500kb. In fact, looking at metrics we've collected with |
| 443 | // rel="expect" examples and other documents, the impact on documents smaller than |
| 444 | // that is within the noise. That's because there's enough happening within that |
| 445 | // start up to not make HTML streaming not significantly better. |
| 446 | // Content above the fold tends to be about 100-200kb tops. Therefore 500kb should |
| 447 | // be enough head room for a good loading state. After that you should use |
| 448 | // Suspense or SuspenseList to improve it. |
| 449 | // Since this is highly related to the reason you would adjust the |
| 450 | // progressiveChunkSize option, and always has to be higher, we define this limit |
| 451 | // in terms of it. So if you want to increase the limit because you have high |
| 452 | // bandwidth users, then you can adjust it up. If you are concerned about even |
| 453 | // slower bandwidth then you can adjust it down. |
| 454 | return request.progressiveChunkSize * 40; // 512kb by default. |
| 455 | } |
| 456 | |
| 457 | function isEligibleForOutlining( |
| 458 | request: Request, |
no outgoing calls
no test coverage detected