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

STRF-4605: Add resourceHints helper #133

Merged
merged 1 commit into from
May 9, 2018
Merged

STRF-4605: Add resourceHints helper #133

merged 1 commit into from
May 9, 2018

Conversation

mattolson
Copy link
Contributor

@mattolson mattolson commented May 9, 2018

  • Extract font logic from getFontsCollection helper to make it reusable
  • Add resourceHints helper that generates a set of 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.
  • This will become 2.0.8 and will need to be ported over to 3.0

_.each(fonts, function fontsIterator(font) {
var split = font.split('_'),
familyKey = split[1], // Eg: Open+Sans
weights = split[2]; // Eg: 400,700italic
Copy link

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

Copy link
Contributor Author

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kk

Copy link

@tpietsch tpietsch left a 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants