You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, we are having font files and fonts declaration in both the component library (this repo) as well as the library consumers (currently just /learn):
Use the fonts from FontSource, in both @freecodecamp/ui and its downstream apps/packages. The fonts will be self-hosted, but FontSource manages the font files as well as handling the fonts declaration for us.
Load the fonts from our CDN
Load the fonts from a third-party CDN (mention for completeness, but I don't think this option is more performant, and there are also privacy implications)
Research
Since a lot of component libraries use Storybook, the Storybook projects page was my first stopping point, and I also looked at other component libraries that I know of / am familiar with.
We usually want to load static assets from CDN for performance optimization, and this approach would help address the DX criteria mentioned above. However, I can't benchmark to be sure if / how the performance is improved.
As for choosing between bundling the fonts and using FontSource, it doesn't really matter because the approaches are essentially the same. We could move to FontSource if we want to reduce the code we have to house/maintain. But realistically, we don't have to touch the font files and fonts.css unless we need to change the fonts, so I think bundling the fonts ourselves is more straight-forward and would give us more control over our package.
I'll let others chime in on the CDN option. If we decide to not go with it, I think including fonts in the bundle should be the action item.
The text was updated successfully, but these errors were encountered:
Description
At the moment, we are having font files and fonts declaration in both the component library (this repo) as well as the library consumers (currently just /learn):
I'm looking into ways we can simplify the fonts management on the consumer end, ideally:
Approaches
Options:
@freecodecamp/ui
bundle, allowing downstream apps/packages to consume:@freecodecamp/ui
and its downstream apps/packages. The fonts will be self-hosted, but FontSource manages the font files as well as handling the fonts declaration for us.Research
Since a lot of component libraries use Storybook, the Storybook projects page was my first stopping point, and I also looked at other component libraries that I know of / am familiar with.
Libraries that bundle fonts:
assets
, which is then consumed by the component package https://github.com/massgov/mayflower/blob/095603602431124feee7a26695ebef64e9ad1b8a/packages/react/src/components/styles/_global.scss#L10Libraries that promote loading fonts from FontSource:
Libraries that load fonts from their own CDN:
Conclusion
We usually want to load static assets from CDN for performance optimization, and this approach would help address the DX criteria mentioned above. However, I can't benchmark to be sure if / how the performance is improved.
As for choosing between bundling the fonts and using FontSource, it doesn't really matter because the approaches are essentially the same. We could move to FontSource if we want to reduce the code we have to house/maintain. But realistically, we don't have to touch the font files and
fonts.css
unless we need to change the fonts, so I think bundling the fonts ourselves is more straight-forward and would give us more control over our package.I'll let others chime in on the CDN option. If we decide to not go with it, I think including fonts in the bundle should be the action item.
The text was updated successfully, but these errors were encountered: