Socket
Socket
Sign inDemoInstall

postcss-reduce-initial

Package Overview
Dependencies
13
Maintainers
7
Versions
40
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-reduce-initial

Reduce initial definitions to the actual initial value, where possible.


Version published
Weekly downloads
8.8M
decreased by-17.91%
Maintainers
7
Install size
2.42 MB
Created
Weekly downloads
 

Package description

What is postcss-reduce-initial?

The postcss-reduce-initial npm package is a PostCSS plugin that optimizes CSS by replacing properties set to their initial values with the 'initial' keyword, thus reducing the size of the CSS file. It can be particularly useful for minimizing the output of CSS preprocessors that tend to output properties with their initial values.

What are postcss-reduce-initial's main functionalities?

Replace properties with 'initial'

This feature takes CSS properties that are set to their initial values and replaces them with the 'initial' keyword. For example, 'min-width: auto;' would be replaced with 'min-width: initial;', and 'transition-duration: 0s;' would be replaced with 'transition-duration: initial;'.

".element {\n  min-width: auto;\n  transition-duration: 0s;\n}"

Other packages similar to postcss-reduce-initial

Readme

Source

postcss-reduce-initial

Reduce initial definitions to the actual initial value, where possible.

Install

With npm do:

npm install postcss-reduce-initial --save

Examples

See the data for more conversions. This data is courtesy of Mozilla.

Convert initial values

When the initial keyword is longer than the property value, it will be converted:

Input
h1 {
  min-width: initial;
}
Output
h1 {
  min-width: 0;
}

Convert values back to initial

When the initial value is smaller than the property value, it will be converted:

Input
h1 {
  transform-box: border-box;
}
Output
h1 {
  transform-box: initial;
}

This conversion is only applied when you supply a browsers list that all support the initial keyword; it's worth noting that Internet Explorer has no support.

API

reduceInitial([options])

options
ignore

Type: Array<String> Default: undefined

It contains the Array of properties that will be ignored while reducing its value to initial. Example : { ignore : ["min-height"] }

Usage

See the PostCSS documentation for examples for your environment.

Contributors

See CONTRIBUTORS.md.

License

This program uses a list of CSS properties derived from data maintained my the MDN team at Mozilla and licensed under the CC0 1.0 Universal Public Domain Dedication.

MIT © Ben Briggs

Keywords

FAQs

Last updated on 28 Oct 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