[Bug]: Resource Hints: preload, fonts, and CORS
Personne n'a encore pris cette issue.
- Langage dominant
- JavaScript
- Étoiles
- 11.8k
- Forks
- 7.9k
- Merge moyen
- 1 j 11 h
- PR mergées (30 j)
- 11
Description
Summary
NOTE: I hope this is the correct place to report this, if not, please let me know and I would be happy to file it in the correct repository.
I like the added support for Resource Hints in the upcoming React 19 release but there seems to be either a bug or an oversight in the docs when it comes to preload as it relates to font loading.
Page
https://react.dev/reference/react-dom/preload
Details
The preload page uses font loading throughout the documentation page as an example use case, but nowhere does it include the use of the crossOrigin property with the anonymous value. Reading over the blog post announcing the release of React 19 beta, there is also an example using font loading which then also shows the following HTML output:
<link rel="preload" as="font" href="https://.../path/to/font.woff">
For reference: https://react.dev/blog/2024/04/25/react-19#support-for-preloading-resources
However, when preloading fonts one needs to always specify crossorigin in order for the resource hint to be respected. More details can be found on the MDN Web Docs website that covers preload.
I would have thought that perhaps React would internally automatically add this for font loading, but at the same time, it might be better for it to be a little less magical 😺 and be more explicit. In the latter case, one would need to update the examples in the docs and the release announcement post and make note of the "special" case of preloading fonts.
I believe this means that font loading should always be done as follows:
preload("https://example.com/font.woff2", {as: "font", crossOrigin: "anonymous"});
Resulting in the following HTML:
<link rel="preload" as="font" href="https://.../path/to/font.woff" crossorigin>
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par la page de référence de react-dom/preload et l’article de blog sur React 19 liés dans l’issue, en localisant les exemples de préchargement de polices et leur contenu source. Mettez à jour les exemples et le texte explicatif pour montrer le paramètre cross-origin anonyme requis pour les polices, puis vérifiez que la documentation rendue et les exemples HTML reflètent systématiquement ces indications.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, react
- Domaine
- documentation
- Type d'issue
- Documentation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 48/100