-
Notifications
You must be signed in to change notification settings - Fork 29
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
[Feature Request] Option to prevent "base64 encode inlining" #155
Comments
We used to have that feature, but removed it for 6.0.0: a85fc9c?diff=unified&w=1 🙈 ... So we can theoretically put it back. However, you're not saying why it's bad? Do you have a case where it's slower than not inlining the font? |
Well, first, I don't like my code changed anywhere unless I define so. Therefore, I would really appreciate having an option. For those who want base64encodes can go for, the ones which don't, don't have to. But yes I would like to load my fonts on a separate file since I Early hint them but not the whole CSS file, or not always. It depends on the site. If it's inlined it takes this option from me. Also, every string/file is bigger when base64encoded. And I, in my case do not safe any data by encoding it. But others might do and therefore I can understand it if people want to use it. Also, this goes against the (eventually) need of modular use. Since I just want to optimize my font file, but nothing else, I would appreciate this function. |
First off, subfont is deliberately an opinionated tool. Catering to every taste and preference would add too much complexity. Performance is the top goal, so if there's a case where it's reproducibly slower to inline the font, we'll take a look. Wrt. the hinting, could you share an example of what your HTML and CSS looks like? |
What performance are you talking about?
Backend performance:Like I said, I have this workaround which just created twice as much exportdata and therefore takes longer to export and creates overhead. I can use this, no problem. So yes, instead of using this hacky workaround the backend performance would definitely be better when this option would be given. Frontend performance:How big the site overall is, isnt all. Its also about how good can you speed up the page? Since fonts should be loaded before CSS to prevent FOUT, FOIT & FOFT, when set the correct font-display. Therefore I like to change the loadingorder to:
this prevents nearly all bad font behaviour. Maybe the code of the website is loaded slower, but the website (text) therefore just needs to be rendered once, not twice (as soon as the font is available). I wouldn't mind to much if you don't realize this as like I said I have the workaround of rendering WOFF2 and additionally (not needed and therefore 100% overhead) WOFF even if I later do not use this at all. |
For the actual website I will drop you a email. Thanks. |
Frontend performance. All of subfont's tradeoffs have pointed in the direction of sacrificing build time for page load improvements.
Thanks for the link to your website! As I understand it, your website contains some existing When (For the record, I think it's a fair use case. I wonder if there's a way to make subfont DTRT by default instead of jumping to adding a switch. Maybe the presence of existing preload tags pointing at some of the original fonts could affect what gets output. Eg. if you preload one out of five fonts, it's a signal that subfont shouldn't base64 inline the other ones? |
Exactly. But keep in mind that I was talking about the link header preload which is getting used for Early Hinting and also for (before it was discontinued) HTTP/2 Pushing. So it beeing in the HTML is not the earliest preload, but beeing in the link header.
Thats true, but I did not implement it with subfont. I have implemented it via my SSG which adds it to the
Since the
Thats makes sense, but like I said, the There is a difference between
|
Ah, I had missed that you were also using the I see how this ties in with #156 and the desire to have subfont perform a direct replacement of your existing fonts with the subset ones, as that would preserve the path and thus not break your existing That's not exactly how subfont operates, though. In the default mode (without In other words doing the direct replacement would be a bit tricky without I think it'll be difficult to get this to work the way you want without at least one mode switch. |
@MartinHotmann, what's your caching strategy btw.? If we made subfont write out the subset fonts at the same location as the original fonts (so the |
Caching strategy is: after successfully overwriting the fonts I use
Actually I don't see a problem there. Even if you set a far-future (1 years I guess) TTL you can change/overwrite this by changing a link, without changing the URL (which is possible by adding a querystring). This is the native way is telling the client, that something changed at this URL. |
Okay, thanks. Well yeah, adding a cache buster to the query string also does the job, although I prefer to include a content hash in the file name itself. That means that I don't ever have to purge anything. |
subfont doing that by default is an attempt to make it play nice with all caching strategies, even when the tool gets applied as the very last step in a build pipeline 😇 |
Thats true, this works flawlessly aswell. I considert implementing this. Just discovered a weird behaviour. the |
Needed a workaround to make subfont do what I want: Munter/subfont#155
I feel like you're overlooking something obvious in the performance discussion: not everything is on the web. So that's relevant for GUI applications, games, powerusers who want to just modify their own fonts, android devs (?) I'm reaching a bit, but point stands. |
That sounds like a convoluted way of using subfont instead of a more minimalistic tool that only does the subsetting, such as https://github.com/papandreou/subset-font
To be honest, that's not a very good argument. |
I have tested subfont and actually like it. Had to create some scripted workarounds for some things.
The first one I would like to talk about here.
When
--formats='woff2'
is given as input parameter subfont inlines the woff2 font base64 encoded into the CSS since this generating a general smaller file.I ATM work around this by adding
--formats='woff2,woff'
. As this creates multiple outputformats, they will not be inlined. Thats a dirty workaround - but it works.I would like to be able to achive the same without having to create the overhead of exporting yet another fontformat (which in this case is not needed).
I really dont like this. A option to prevent that would be awesome. Something like "
--no-base64
"The text was updated successfully, but these errors were encountered: