Socket
Socket
Sign inDemoInstall

postcss-minify-font-values

Package Overview
Dependencies
5
Maintainers
8
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-minify-font-values

Minify font declarations with PostCSS


Version published
Weekly downloads
11M
increased by2.77%
Maintainers
8
Install size
44.3 kB
Created
Weekly downloads
 

Package description

What is postcss-minify-font-values?

The postcss-minify-font-values npm package is designed to optimize font declarations in CSS to ensure they are as short and efficient as possible. It works by minimizing font-weight values, removing duplicate font-family names, and condensing font shorthand declarations where possible.

What are postcss-minify-font-values's main functionalities?

Minifying font-weight values

Converts named font-weight values to their numeric equivalents, reducing the size of the CSS file.

"font-weight: normal;" // Before minification
"font-weight: 400;" // After minification

Removing duplicate font-family names

Eliminates redundant font-family names from the font-family list, making the declaration shorter.

"font-family: Arial, Arial, sans-serif;" // Before minification
"font-family: Arial, sans-serif;" // After minification

Condensing font shorthand declarations

Simplifies font shorthand declarations by removing unnecessary or default values, further reducing CSS size.

"font: italic normal bold 12px/30px Arial, sans-serif;" // Before minification
"font: italic bold 12px/30px Arial, sans-serif;" // After minification

Other packages similar to postcss-minify-font-values

Readme

Source

postcss-minify-font-values Build Status

Minify font declarations with PostCSS.

This module will try to minimise the font-family, font-weight and font shorthand properties; it can unquote font families where necessary, detect & remove duplicates, and cut short a declaration after it finds a keyword. For more examples, see the tests.

h1 {
  font:bold 2.2rem/.9 "Open Sans Condensed", sans-serif;
}

p {
  font-family: "Helvetica Neue", Arial, sans-serif, Helvetica;
  font-weight: normal;
}
h1 {
  font:700 2.2rem/.9 Open Sans Condensed,sans-serif
}

p {
  font-family: Helvetica Neue,Arial,sans-serif;
  font-weight: 400;
}

API

minifyFontValues([options])

options
removeAfterKeyword

Type: boolean Default: false

Pass true to remove font families after the module encounters a font keyword, for example sans-serif.

removeDuplicates

Type: boolean Default: true

Pass false to disable the module from removing duplicated font families.

removeQuotes

Type: boolean Default: true

Pass false to disable the module from removing quotes from font families. Note that oftentimes, this is a safe optimisation & is done safely. For more details, see Mathias Bynens' article.

Usage

postcss([ require('postcss-minify-font-values') ])

See PostCSS docs for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

MIT © Bogdan Chadkin

Keywords

FAQs

Last updated on 01 Mar 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc