Strip font-faces not used
See original GitHub issueIf you run ./bin/minimalcss.js -o /tmp/peterbe.css https://www.peterbe.com/search\?q\=css
that CSS will contain this:
@font-face {
font-family: 'Rating';
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMggjCBsAAAC8AAAAYGNtYXCj2pm8AAABHAAAAKRnYXNwAAAAEAAAAcAAAAAIZ[ ...15,330 bytes snipped... ]AAAAAAAAAAAAAAAAAA==) format('woff');
font-weight: 400;
font-style: normal
}
But there is NO selector that contains something like
font-family: Rating;
So this font-face can be removed.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Custom fonts are not displayed in Stripe elements #179
I use custom fonts in my project, including them in CSS through @font-face. E. g.: @font-face{ font-family: AvenirLTStd-Roman; ...
Read more >How to check which fonts are loaded but not used on a website?
Is there an easy way to check which ones are not used so that I delete corresponding @font-face declarations and the user won't...
Read more >Remove, deactivate, or activate fonts in Font Book on Mac
In the Font Book app on your Mac, select one or more deactivated fonts, or a deactivated font collection. Choose Edit > Activate....
Read more >Remove or subset embedded fonts from Office Files to ...
Non-system fonts used in Office files will be embedded by default when the file is saved. So a full copy of the entire...
Read more >Manage your fonts - Adobe Support
We recommend removing fonts you no longer use to keep your font menu ... use the Deactivate switch next to a font family...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@peterbe Thanks for mention of me!
Yep, new CSSTree version is coming (very soon, I believe) and it will bring a changes for the walk API. Instead of several walk methods, there will be just one –
walk()
with notationwalk(ast, options)
(current notationwalk(ast, fn)
continues to work). Byoptions
you can setenter
and/orleave
handlers, which allows you to organise a stack or any other context needed structures (to figure out “where we came” from and so on).Btw, currently walk handlers get a context (via
this
) that points at some node types likeAtrule
,Rule
and so on (some details can be found in docs). Unfortunately, it doesn’t work well (as expected) and probably will be removed or replaced for better solution.Some additional inspiration https://github.com/Munter/subfont