Introduce new optimization levels
See original GitHub issueSee https://github.com/jakubpawlowicz/clean-css/issues/842#issue-196045322
In API:
- level 0 - no optimizations at all (see #836), e.g
new CleanCSS({ level: 0 })
- level 1 - just basic optimizations (new default), e.g.
new CleanCSS({ level: 1 })
, also supports more granular level over what gets optimizednew CleanCSS({ level: { 1: { urlQuotes: true, timeUnits: false } } })
- level 2 - advanced optimizations (old default), e.g.
new CleanCSS({ level: 2 })
, also supports more granular level over what gets optimized, e.g. (see #813)new CleanCSS({ level: { 2: { all: false, removeDuplicates: true } } })
Also when using level 2 one could configure level 1, e.g.
new CleanCSS({ level: { 1: { urlQuotes: true }, 2: { all: false, removeDuplicates: true } } })
and accordingly in CLI:
- level 0 -
cleancss -O0
- level 1 -
cleancss -O1
andcleancss -O1 urlQuotes:true,timeUnits:false
- level 2 -
cleancss -O2
andcleancss -O2 all:false,removeDuplicates:true
Mixing level configurations: cleancss -O1 urlQuotes:true -O2 all:false,removeDuplicates:true
- (is this the best way?).
Question: compatibility and rounding precision have a slightly different configuration styles, so should we allow the following?
cleancss -O1 +urlQuotes,-timeUnits
cleancss -O1 urlQuotes:on,timeUnits:off
cleancss -O2 -all,+removeDuplicates
Help / readme will list all available options with safe ones turned on by default.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
An Introduction to GCC - Optimization levels - Linuxtopia
An optimization level is chosen with the command line option -O LEVEL , where LEVEL is a number from 0 to 3. The...
Read more >Optimize Options (Using the GNU Compiler Collection (GCC))
Without any optimization option, the compiler's goal is to reduce the cost of compilation and to make debugging produce the expected results. Statements...
Read more >4.2. Optimization levels — C2000™ C28x Optimization Guide
Table 4.2 lists the optimization levels available, the scope of each level and some examples of optimizations performed at each level.
Read more >Arm Compiler for Embedded User Guide - Arm Developer
Arm Compiler for Embedded provides various optimization levels to control the different optimization goals. The best optimization level for your application ...
Read more >GCC optimization - Gentoo Wiki
This guide provides an introduction to optimizing compiled code using safe, ... a new general optimization level, -Og , has been introduced.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This will be the new way, backwards incompatible. So your example will turn into
{ level: { 1: { keepSpecialComments: 0 } } }
.This way all options will be scoped to the proper level, i.e. removing comments is a level 1 optimization. Here’s the full mapping:
{ advanced: true }
->{ level: 2 }
{ aggressiveMerging: true }
-> gone in 4.x{ keepSpecialComments: 0 }
->{ level: { 1: { keepSpecialComments: 0 } } }
{ mediaMerging: true }
->{ level: { 2: { mediaMerging: true } } }
{ restructuring: true }
->{ level: { 2: { restructuring: true } } }
{ roundingPrecision: 6 }
->{ level: { 1: { roundingPrecision: 6 } } }
{ semanticMerging: true }
->{ level: { 2: { semanticMerging: true } } }
{ shorthandCompacting: true }
->{ level: { 2: { shorthandCompacting: true } } }
It’d a bit more verbose but very likely the last change needed. Also keeping all these options unscoped (and we’ll have more!) is impractical.
We should make sure it’s all well explained in readme.
It turned out to work fine, save a hack to extract level 1/2 options. Merging it to master now.