MCPcopy
hub / github.com/QwikDev/qwik / preload

Function preload

packages/qwik/src/core/preloader/queue.ts:234–257  ·  view source on GitHub ↗
(name: string | (number | string)[], probability?: number)

Source from the content-addressed store, hash-verified

232let depsCount: number;
233
234export const preload = (name: string | (number | string)[], probability?: number) => {
235 if (!name?.length) {
236 return;
237 }
238 depsCount = 0;
239
240 let inverseProbability = probability ? 1 - probability : 0.4;
241 if (Array.isArray(name)) {
242 // We must process in reverse order to ensure first bundles are handled first
243 for (let i = name.length - 1; i >= 0; i--) {
244 const item = name[i];
245 if (typeof item === 'number') {
246 inverseProbability = 1 - item / 10;
247 } else {
248 handleBundle(item, inverseProbability);
249 }
250 }
251 } else {
252 handleBundle(name, inverseProbability);
253 }
254 if (isBrowser) {
255 trigger();
256 }
257};
258
259if (isBrowser) {
260 // Get early hints from qwikloader

Callers 5

expandBundlesFunction · 0.90
queue.tsFile · 0.85
resolveFunction · 0.85
createQRLFunction · 0.85
preloadRouteBundlesFunction · 0.85

Calls 2

handleBundleFunction · 0.85
triggerFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…