-
Notifications
You must be signed in to change notification settings - Fork 24
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
STRF-4605: Add resourceHints helper #133
Conversation
_.each(fonts, function fontsIterator(font) { | ||
var split = font.split('_'), | ||
familyKey = split[1], // Eg: Open+Sans | ||
weights = split[2]; // Eg: 400,700italic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there another way than index? Regex would be safer + maybe a catch or something incase font doesnt have underscores
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is existing code that I didn't spend time refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would imagine there may be some public JS lib around font parsing or something.
* Extract font logic from getFontsCollection helper to make it reusable * Add resourceHints helper that generates a set of <link> tags for preconnect and dns-prefetch resource hints. This uses the font parsing logic from getFontsCollection helper to determine which font providers are used for the theme, and adds resource hints for expected hosts for these font providers. Also add one for the cdn host. * Add getFontLoaderConfig helper that generates a config suitable for use in Web Font Loader.
resourceHints
helper that generates a set of tags forpreconnect and dns-prefetch resource hints. This uses the font parsing
logic from getFontsCollection helper to determine which font providers
are used for the theme, and adds resource hints for expected hosts
for these font providers. Also add one for the cdn host.
getFontLoaderConfig
helper that generates a config suitable foruse in Web Font Loader.