Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/twelve-words-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

FEAT: maxIdlePreloads is now constant over time so you know for sure how many bundles will be preloaded concurrently during idle.
2 changes: 1 addition & 1 deletion packages/qwik/src/core/preloader/preloader.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ test('preloader script', () => {
* dereference objects etc, but that actually results in worse compression
*/
const compressed = compress(Buffer.from(preLoader), { mode: 1, quality: 11 });
expect([compressed.length, preLoader.length]).toEqual([1863, 5533]);
expect([compressed.length, preLoader.length]).toEqual([1818, 5417]);
});
7 changes: 3 additions & 4 deletions packages/qwik/src/core/preloader/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,9 @@ export const trigger = () => {
const inverseProbability = bundle.$inverseProbability$;
const probability = 1 - inverseProbability;
const allowedPreloads = graph
? // The more likely the bundle, the more simultaneous preloads we want to allow
Math.max(1, config.$maxIdlePreloads$ * probability)
: // While the graph is not available, we limit to 2 preloads
2;
? config.$maxIdlePreloads$
: // While the graph is not available, we limit to 5 preloads
5;
// When we're 99% sure, everything needs to be queued
if (probability >= 0.99 || preloadCount < allowedPreloads) {
queue.shift();
Expand Down
Loading