Optimizing icon-fonts CSS size
When using an icon fonts, you usually take a pack of hundreds of icons resulting in hundreds of CSS lines.
This methods allows you to only output the CSS you need.
- By default, all icons are disabled
- When you need an icon, you set the 3rd parameter of its list to "true"
- This outputs only the CSS for icons you need
$icons: (star, '\f005', true), (star-empty, '\f006', false);
Outputs:
.font-awesome-star:before { content: '\f005' }
This isn't limited to Font Awesome, you can do this for pretty much any font you want. You only have to make the
$icons
list, but it's pretty easy with an IDE like Sublime Text.