Skip to content
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

Support for preconnect link relationship for Google Fonts #43

Open
ryanbalsdon opened this issue Jul 11, 2023 · 1 comment
Open

Support for preconnect link relationship for Google Fonts #43

ryanbalsdon opened this issue Jul 11, 2023 · 1 comment

Comments

@ryanbalsdon
Copy link

Google Fonts asks you to include two preconnect links when using one of their fonts. The link tags when copied from the Google Fonts site look like this:

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">

The rel attribute of links is parsed with a LinkType enum that is missing a few valid values. This LinkType enum is also used for a tags so a straight copy/paste into the enum might not be enough because not all types are supported in both tags!

@ryanbalsdon
Copy link
Author

For a bit more context, here is the list of supported tokens for link relationships:
alternate, dns-prefetch, icon, manifest, modulepreload, next, pingback, preconnect, prefetch, preload, search, and stylesheet

And the same list of supported tokens for anchor relationships:
noreferrer, noopener, and opener

The Mozilla docs have a much larger list (some of these are not supported across both link and anchor elements though):
alternate, author, bookmark, canonical, dns, external, help, icon, license, manifest, me, modulepreload, next, nofollow, noopener, noreferrer, opener, pingback, preconnect, prefetch, preload, prerender, prev, search, stylesheet, tag

For context, here is the list currently supported (this does not distinguish between links and anchors):
alternate, author, bookmark, canonical, external, help, icon, license, manifest, modulepreload, next, nofollow, noopener, noreferrer, pingback, prefetch, preload, prev, search, shortlink, stylesheet, tag

Other than dns vs dns-prefetch, the Mozilla docs are a superset so probably are including historical or deprecated tokens? Looks like there are only about 4 currently missing in LinkType. I don't mind adding them in a small PR but would it be better to split these tokens into two separate lists (one for links and one for anchors)? Splitting into two lists might not be a backward-compatible change if anyone is currently using LinkType inside their anchor elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant