question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Strip font-faces not used

See original GitHub issue

If 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
lahmatiycommented, Jan 8, 2018

@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 notation walk(ast, options) (current notation walk(ast, fn) continues to work). By options you can set enter and/or leave 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 like Atrule, 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.

1reaction
stereoboostercommented, Jan 5, 2018

Some additional inspiration https://github.com/Munter/subfont

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found