[Typo]: definitions of async/defer in the script tag documentation are incorrect
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Documentazione
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- documentation
Direzione di ricerca
Apri la documentazione degli script di React DOM all’indirizzo https://react.dev/reference/react-dom/components/script e confronta le descrizioni di async e defer con la specifica DOM di MDN collegata. Aggiorna la formulazione per distinguere accuratamente i relativi tempi di esecuzione, il comportamento durante il parsing e l’applicabilità agli script esterni, quindi verifica che la pagina comunichi chiaramente le implicazioni a runtime.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
Unless React has its own creative interpretation of the meanings of async and defer that are different from the DOM specification (per MDN), the descriptions for async and defer are confusing and misleading and may lead to runtime errors.
Page
https://react.dev/reference/react-dom/components/script
Details
The description for async confounds it with defer, but in fact async essentially cancels any kind of defer: the script will not block further parsing, but it will be executed as soon as it is available, there is no "deferring". This lets the browser execute it at its convenience, there is no longer any guarantee about when it runs other than "eventually": this can even be mid-parse!
defer, on the other hand, also doesn't block parsing by enqueueing the script to run after the page finishes parsing; but they are guaranteed to run before the DOMContentLoaded event. This is, actually, what is recommended for most scripts, enough that it is the default for script[type="module"]. It is canceled by async, as it removes the guarantee that the script will run only after parse is done. It only has an effect on src scripts, though, not inline.
It is, however, true that async is the best for performance, as there is no longer any execution time guarantees. It is also dangerous, as the DOM might not be available when the script runs: only (non-async) defer scripts have that guarantee.
- Lingua principale
- JavaScript
- Stelle
- 11.8k
- Fork
- 7.9k
- Merge medio
- 16h 6m
- PR unite (30g)
- 7
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di reactjs/react.dev
-
type: documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
-
bug: unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
type: typos
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
bug: unconfirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Tutte le issue di reactjs/react.dev
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Seeed-Studio/wiki-documents#5655 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
Edit: CW+ Apertachannels:edit check:passed
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
01 type: bug 30 needs: triage 99 tag: UX Accessibility
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
quarto-dev/quarto-cli#14915 ·