A click before the page's load event gets no preloading: the preloader only starts after load

Aperta
#9,512 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
54/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, typescript

Direzione di ricerca

Start by reading e2e/preloader-e2e/tests/early-clicks-and-failed-loads.e2e.ts and the qwikloader changes referenced in #9496, then run pnpm build.core and pnpm test.e2e.preloader -g "slow image". Trace how user events and visible tasks queue chunks and start the preloader. Done when the early click completes in 2 round trips while visible tasks still do not trigger speculative preloads before load.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

preloader V2

Part of #9434.

The preloader only starts after the page's load event, then two frames and idle time:

window.addEventListener('load', () =>
  requestAnimationFrame(() =>
    requestAnimationFrame(() => requestIdleCallback(startPreloader, { timeout: 1000 }))
  )
);

One slow image, iframe or third-party script holds that event back. A click made in the meantime gets no preloading, even when the preloader chunk and the bundle graph are already downloaded: each chunk is only found once the one before it has loaded. On conditional/all that click takes 11 round trips; the same click after load takes 2.

Possible fix

Start the preloader on the first user event instead of waiting for load. Since #9496 qwikloader already tells user events apart and queues their chunks in qPreloadQueue, but it does not start the preloader.

Visible tasks go through qwikloader too (qvisible, qinit, qidle) and fire while the page is loading. Their chunks are highest priority preloads, so they can start the preloader as well (#9441); only the speculative preloads must still wait for load.

Pinned by e2e/preloader-e2e/tests/early-clicks-and-failed-loads.e2e.ts (added by #9509):

  • click before the page has finished loading › a slow image holds back the load event: the click shows its result in 11 round trips, over the cap of 2 (count over the cap)

Run it

pnpm build.core
pnpm test.e2e.preloader -g "slow image"

Done when the click shows its result in 2 round trips, and a page with a visible task still starts no speculative preload before load.

Lingua principale
TypeScript
Stelle
22.1k
Fork
1.4k
Merge medio
1g 13h
PR unite (30g)
159

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di QwikDev/qwik

Tutte le issue di QwikDev/qwik

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.