No description
Find a file
Robin Malfait b9af5a916b
Improve collapsing of duplicate declarations (#6856)
* improve collapsing of duplicate properties

In theory, we don't have to do anything because the browser is smart
enough to figure everything out. However, leaving in duplicate
properties is not that ideal for file size.

Our previous method was pretty simple: if you see a declaration you
already saw in this rule, delete the previous one and keep the current
one.

This works pretty well, but this gets rid of **all** the declarations
with the same property. This is not great for overrides for older
browsers.

In a perfect world, we can handle this based on your target browser but
this is a lot of unnecessary complexity and will slow things down
performance wise.

Alternative, we improved the solution by being a bit smarter:
1. Delete duplicate declarations that have the same property and value
   (this will get rid of **exact** duplications).
2. Delete declarations with the same property and the same **unit**.

This means that we will reduce this:
```css
.example {
  height: 50%;
  height: 100px;
  height: 20vh;
  height: 30%;
  height: 50px;
  height: 30vh;
  transform: var(--value);
  transform: var(--value);
}
```

To:
```diff-css
  .example {
-   height: 50%;    /* Another height exists later with a `%` unit */
-   height: 100px;  /* Another height exists later with a `px` unit */
-   height: 20vh;   /* Another height exists later with a `vh` unit */
    height: 30%;
    height: 50px;
    height: 30vh;
-   transform: var(--value); /* Value is too complex, but is **exactly** the same as the one below */
    transform: var(--value);
  }
```

This will reduce the values that we are 100% sure that can be safely
removed. This will still result in some overrides but the browser can
handle those for you.

Fixes: #6844

* update changelog
2022-01-03 15:41:49 +01:00
.github Add standalone-cli node16-linux-arm64 build (#6693) 2021-12-28 16:06:49 -05:00
integrations make version number dynamic in the test (#6017) 2021-11-08 21:30:37 +01:00
jest JIT: Optimize universal selector usage by inlining only the relevant selectors (#4850) 2021-07-01 06:33:37 -04:00
nesting Remove AOT (#5340) 2021-09-01 17:13:59 +02:00
perf Performance improvements + memory leak fix (#3032) 2020-12-11 15:03:49 +01:00
scripts Polish match APIs (#5664) 2021-10-01 17:31:09 +02:00
src Improve collapsing of duplicate declarations (#6856) 2022-01-03 15:41:49 +01:00
standalone-cli Add standalone-cli node16-linux-arm64 build (#6693) 2021-12-28 16:06:49 -05:00
stubs Improve order of color properties in transition and transition-colors utilities 2021-12-15 14:09:27 -05:00
tests Improve collapsing of duplicate declarations (#6856) 2022-01-03 15:41:49 +01:00
.editorconfig Convert new stuff to use ES6 modules 2017-08-27 18:02:41 -04:00
.eslintignore Generate plugin list file (#4725) 2021-06-23 14:13:03 -04:00
.eslintrc.json Remove duplicate prettier.config.js settings from .eslintrc.json (#5087) 2021-09-01 17:41:43 +02:00
.gitignore Ignore .DS_Store (#6005) 2021-11-23 15:23:18 -05:00
.swcrc Switch to swc from babel (#5593) 2021-09-24 19:17:19 +02:00
base.css Remove preflight CSS export in favor of base 2019-02-11 12:38:46 -05:00
CHANGELOG.md Improve collapsing of duplicate declarations (#6856) 2022-01-03 15:41:49 +01:00
colors.js Add default interop to public available functions (#6348) 2021-12-10 11:25:10 +01:00
components.css Move CSS files to root for easier imports 2018-03-13 10:05:24 -04:00
defaultConfig.js Add default interop to public available functions (#6348) 2021-12-10 11:25:10 +01:00
defaultTheme.js Add default interop to public available functions (#6348) 2021-12-10 11:25:10 +01:00
LICENSE Avoid updating license every year 2017-12-29 22:32:43 +01:00
package-lock.json Update jest to version 27.4.5 2021-12-29 14:15:05 +00:00
package.json Update jest to version 27.4.5 2021-12-29 14:15:05 +00:00
plugin.js Add default interop to public available functions (#6348) 2021-12-10 11:25:10 +01:00
prettier.config.js Add Prettier configuration file (prettier.config.js) (#3713) 2021-05-13 09:07:24 -04:00
README.md Update logo in readme 2021-12-17 15:25:53 -05:00
resolveConfig.js Add default interop to public available functions (#6348) 2021-12-10 11:25:10 +01:00
screens.css Add screen.css file for postcss-import convenience 2019-05-12 10:36:59 -04:00
tailwind.css Undo accidental changes to CDN build process 2019-12-25 13:54:09 -05:00
utilities.css Move CSS files to root for easier imports 2018-03-13 10:05:24 -04:00
variants.css JIT: Replace @tailwind screens with @tailwind variants (#4356) 2021-05-14 13:58:52 -04:00

Tailwind CSS Tailwind CSS

A utility-first CSS framework for rapidly building custom user interfaces.

Build Status Total Downloads Latest Release License


Documentation

For full documentation, visit tailwindcss.com.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Tailwind CSS on GitHub

For casual chit-chat with others using the framework:

Join the Tailwind CSS Discord Server

Contributing

If you're interested in contributing to Tailwind CSS, please read our contributing docs before submitting a pull request.