Skip to content

refactor(preloader): rename maxBufferPreloads #7527

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

Merged
merged 1 commit into from
Apr 20, 2025
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
2 changes: 1 addition & 1 deletion .changeset/fair-cars-fry.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default function (opts: RenderToStreamOptions) {
// Enable debug logging for preload operations
debug: true,
// Maximum simultaneous preload links
maxBufferPreloads: 5,
maxBufferedPreloads: 5,
// Minimum probability threshold for preloading
preloadProbability: 0.25
// ...and more, see the type JSDoc on hover
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/entry.ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Root from './root';
const preloaderSettings = [
'ssrPreloads',
'ssrPreloadProbability',
'maxBufferPreloads',
'maxBufferedPreloads',
'preloadProbability',
] as const;

Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/qwik-server/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
}
],
"kind": "Interface",
"content": "```typescript\nexport interface PreloaderOptions \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[debug?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nboolean\n\n\n</td><td>\n\n_(Optional)_ Log preloader debug information to the console.\n\nDefaults to `false`\n\n\n</td></tr>\n<tr><td>\n\n[maxBufferPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of simultaneous preload links that the preloader will maintain. If you set this higher, the browser will have all JS files in memory sooner, but it will contend with other resource downloads. Furthermore, if a bundle suddenly becomes more likely, it will have to wait longer to be preloaded.\n\nBundles that reach 100% probability (static imports of other bundles) will always be preloaded immediately, no limit.\n\nDefaults to `25`\n\n\n</td></tr>\n<tr><td>\n\n[preloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added to the preload queue.\n\nDefaults to `0.35` (35% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added as a preload link during SSR.\n\nDefaults to `0.7` (70% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of preload links to add during SSR. These instruct the browser to preload likely bundles before the preloader script is active. This most likely includes the core and the preloader script itself. Setting this to 0 will disable all preload links.\n\nPreload links can delay LCP, which is a Core Web Vital, but it can increase TTI, which is not a Core Web Vital but more noticeable to the user.\n\nDefaults to `5`\n\n\n</td></tr>\n</tbody></table>",
"content": "```typescript\nexport interface PreloaderOptions \n```\n\n\n<table><thead><tr><th>\n\nProperty\n\n\n</th><th>\n\nModifiers\n\n\n</th><th>\n\nType\n\n\n</th><th>\n\nDescription\n\n\n</th></tr></thead>\n<tbody><tr><td>\n\n[debug?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nboolean\n\n\n</td><td>\n\n_(Optional)_ Log preloader debug information to the console.\n\nDefaults to `false`\n\n\n</td></tr>\n<tr><td>\n\n[maxBufferedPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of simultaneous preload links that the preloader will maintain. If you set this higher, the browser will have all JS files in memory sooner, but it will contend with other resource downloads. Furthermore, if a bundle suddenly becomes more likely, it will have to wait longer to be preloaded.\n\nBundles that reach 100% probability (static imports of other bundles) will always be preloaded immediately, no limit.\n\nDefaults to `25`\n\n\n</td></tr>\n<tr><td>\n\n[preloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added to the preload queue.\n\nDefaults to `0.35` (35% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloadProbability?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ The minimum probability for a bundle to be added as a preload link during SSR.\n\nDefaults to `0.7` (70% probability)\n\n\n</td></tr>\n<tr><td>\n\n[ssrPreloads?](#)\n\n\n</td><td>\n\n\n</td><td>\n\nnumber\n\n\n</td><td>\n\n_(Optional)_ Maximum number of preload links to add during SSR. These instruct the browser to preload likely bundles before the preloader script is active. This most likely includes the core and the preloader script itself. Setting this to 0 will disable all preload links.\n\nPreload links can delay LCP, which is a Core Web Vital, but it can increase TTI, which is not a Core Web Vital but more noticeable to the user.\n\nDefaults to `5`\n\n\n</td></tr>\n</tbody></table>",
"editUrl": "https://github.com/QwikDev/qwik/tree/main/packages/qwik/src/server/types.ts",
"mdFile": "qwik.preloaderoptions.md"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docs/src/routes/api/qwik-server/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ Defaults to `false`
</td></tr>
<tr><td>

[maxBufferPreloads?](#)
[maxBufferedPreloads?](#)

</td><td>

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/preloader/bundle-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const loadBundleGraph = (
config.$DEBUG$ = !!opts.d;
}
if ('P' in opts) {
config.$maxBufferPreloads$ = opts['P'] as number;
config.$maxBufferedPreloads$ = opts['P'] as number;
}
if ('Q' in opts) {
config.$invPreloadProbability$ = 1 - (opts['Q'] as number);
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/preloader/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const preloadStr = 'preload';

export const config = {
$DEBUG$: false,
$maxBufferPreloads$: 25,
$maxBufferedPreloads$: 25,
$invPreloadProbability$: 0.65,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/core/preloader/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const trigger = () => {
const probability = 1 - inverseProbability;
const allowedPreloads = graph
? // The more likely the bundle, the more simultaneous preloads we want to allow
Math.max(1, config.$maxBufferPreloads$ * probability)
Math.max(1, config.$maxBufferedPreloads$ * probability)
: // While the graph is not available, we limit to 2 preloads
2;
// When we're 100% sure, everything needs to be queued
Expand Down
2 changes: 1 addition & 1 deletion packages/qwik/src/server/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface PrefetchStrategy {
// @public (undocumented)
export interface PreloaderOptions {
debug?: boolean;
maxBufferPreloads?: number;
maxBufferedPreloads?: number;
preloadProbability?: number;
ssrPreloadProbability?: number;
ssrPreloads?: number;
Expand Down
8 changes: 4 additions & 4 deletions packages/qwik/src/server/preload-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function includePreloader(
if (referencedBundles.length === 0 || options === false) {
return null;
}
const { ssrPreloads, ssrPreloadProbability, debug, maxBufferPreloads, preloadProbability } =
const { ssrPreloads, ssrPreloadProbability, debug, maxBufferedPreloads, preloadProbability } =
normalizePreLoaderOptions(typeof options === 'boolean' ? undefined : options);
let allowed = ssrPreloads;

Expand Down Expand Up @@ -70,8 +70,8 @@ export function includePreloader(
if (debug) {
opts.push('d:1');
}
if (maxBufferPreloads) {
opts.push(`P:${maxBufferPreloads}`);
if (maxBufferedPreloads) {
opts.push(`P:${maxBufferedPreloads}`);
}
if (preloadProbability) {
opts.push(`Q:${preloadProbability}`);
Expand Down Expand Up @@ -128,6 +128,6 @@ const PreLoaderOptionsDefault: Required<PreloaderOptions> = {
ssrPreloads: 5,
ssrPreloadProbability: 0.7,
debug: false,
maxBufferPreloads: 25,
maxBufferedPreloads: 25,
preloadProbability: 0.35,
};
2 changes: 1 addition & 1 deletion packages/qwik/src/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface PreloaderOptions {
*
* Defaults to `25`
*/
maxBufferPreloads?: number;
maxBufferedPreloads?: number;
/**
* The minimum probability for a bundle to be added to the preload queue.
*
Expand Down