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

Vendor Google fonts in #4864

Closed

Conversation

SISheogorath
Copy link
Contributor

This patch used google-font-downloader[1] to generate a fonts directory
that contains the used Google fonts for shields.io. There are bunch of
reasons for vendoring fonts in, but the first and most important one is
privacy.[2] Another is performance.[3] And the third one is reducing
external dependencies. Keeping those small helps to prevent unexpected
breaking of web interfaces just due to changes or failure of an external
service provider.

1: https://github.com/Bloggify/google-font-downloader
2: google/fonts#1495
3: https://csswizardry.com/2019/05/self-host-your-static-assets/

@shields-ci
Copy link

shields-ci commented Apr 3, 2020

Messages
📖 ✨ Thanks for your contribution to Shields, @SISheogorath!

Generated by 🚫 dangerJS against 9947abb

This patch used `google-font-downloader`[1] to generate a fonts directory
that contains the used Google fonts for shields.io. There are bunch of
reasons for vendoring fonts in, but the first and most important one is
privacy.[2] Another is performance.[3] And the third one is reducing
external dependencies. Keeping those small helps to prevent unexpected
breaking of web interfaces just due to changes or failure of an external
service provider.

[1]: https://github.com/Bloggify/google-font-downloader
[2]: google/fonts#1495
[3]: https://csswizardry.com/2019/05/self-host-your-static-assets/
@paulmelnikow
Copy link
Member

Hi! Thanks for this contribution. I'll be curious to hear others' thoughts on this. Here are a few of my own.

Reducing repo dependencies is almost a non-goal for Shields. We try to be judicious about what we maintain ourselves. For example, we avoid maintaining our own logos; instead we pull them in from Simple Icons. Adding dependencies is often a good way to avoid maintenance work.

That said, reducing external runtime dependencies for the user of the website is a reasonable thing to consider. This is especially true for people who host their own copy of Shields. I can totally seem self-hosting users preferring to host their fonts themselves.

To accommodate that, I'd be happy to include tooling which runs google-font-downloader at build time, and either making it opt-in for self-hosting users, or maybe even turned on by default (though not necessarily turned on for https://shields.io, see below).

For users of https://shields.io/ I am not sure hosting the fonts ourselves improves performance. It seems likely it would reduce performance. If the fonts are already in their browsers' cache from Google Fonts, which is likely, they would be redownloaded. Also, I think the cache would be invalidated on each deploy, unless we did some extra work to ensure longer cache timeouts on those assets, meaning the fonts would frequently be redownloaded.

Privacy and regulatory compliance is another matter. If there's an argument to be made that Shields' no tracking promise means the public website shouldn't depend on Google Fonts, that decision probably should happen in an issue first.

@paulmelnikow paulmelnikow added frontend The React app and the infrastructure that supports it self-hosting Discussion, problems, features, and documentation related to self-hosting Shields labels Apr 3, 2020
@paulmelnikow
Copy link
Member

Feel free to open an issue to discuss further!

@SuperSandro2000
Copy link

For users of shields.io I am not sure hosting the fonts ourselves improves performance.

This needs real live testing and not guessing.

It seems likely it would reduce performance.

I don't think so. Setting good cache header is far more important to not generate to many requests.

If the fonts are already in their browsers' cache from Google Fonts, which is likely, they would be redownloaded.

Which is kinda unlikely since Chrome 77. See https://www.chromestatus.com/feature/5730772021411840 . Cache isn't global anymore so I would have to visit shields.io to cache the font.

Also, I think the cache would be invalidated on each deploy, unless we did some extra work to ensure longer cache timeouts on those assets, meaning the fonts would frequently be redownloaded.

Stick a cache-control or etag header on the response and don't change the URL with each deploy. Does not sound as hard to do.

SISheogorath added a commit to SISheogorath/shields that referenced this pull request Mar 16, 2021
This patch uses the fontsource libraries instead of using Google Fonts
in order to provide the fonts in the frontend. This way the web frontend
becomes more private, since it no longer shared visitors IPs with Google
and might even loads faster since modern web browsers isolate site
caches from each other and can re-use connections with HTTP/2 instead of
setting up a new connection to Google.[1]

It's basically the next iteration of my previous PR[2], that no longer
relies on a tool to download the fonts separately, but uses a library
instead. It also relates to issues that have been opened before[3] and
should be easily handled and upgraded by the regular NPM package
tooling[4], solving all related problems to that.

[1]: https://csswizardry.com/2019/05/self-host-your-static-assets/
[2]: badges#4864
[3]: badges#5883
[4]: https://github.com/badges/shields/labels/dependencies
SISheogorath added a commit to SISheogorath/shields that referenced this pull request Mar 16, 2021
This patch uses the fontsource libraries instead of using Google Fonts
in order to provide the fonts in the frontend. This way the web frontend
becomes more private, since it no longer shared visitors IPs with Google
and might even loads faster since modern web browsers isolate site
caches from each other and can re-use connections with HTTP/2 instead of
setting up a new connection to Google.[1]

It's basically the next iteration of my previous PR[2], that no longer
relies on a tool to download the fonts separately, but uses a library
instead. It also relates to issues that have been opened before[3] and
should be easily handled and upgraded by the regular NPM package
tooling[4], solving all related problems to that.

[1]: https://csswizardry.com/2019/05/self-host-your-static-assets/
[2]: badges#4864
[3]: badges#5883
[4]: https://github.com/badges/shields/labels/dependencies
PyvesB pushed a commit that referenced this pull request Mar 16, 2021
This patch uses the fontsource libraries instead of using Google Fonts
in order to provide the fonts in the frontend. This way the web frontend
becomes more private, since it no longer shared visitors IPs with Google
and might even loads faster since modern web browsers isolate site
caches from each other and can re-use connections with HTTP/2 instead of
setting up a new connection to Google.[1]

It's basically the next iteration of my previous PR[2], that no longer
relies on a tool to download the fonts separately, but uses a library
instead. It also relates to issues that have been opened before[3] and
should be easily handled and upgraded by the regular NPM package
tooling[4], solving all related problems to that.

[1]: https://csswizardry.com/2019/05/self-host-your-static-assets/
[2]: #4864
[3]: #5883
[4]: https://github.com/badges/shields/labels/dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend The React app and the infrastructure that supports it self-hosting Discussion, problems, features, and documentation related to self-hosting Shields
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants