question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Introduce new optimization levels

See original GitHub issue

See 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 optimized new 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 and cleancss -O1 urlQuotes:true,timeUnits:false
  • level 2 - cleancss -O2 and cleancss -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:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jakubpawlowiczcommented, Jan 5, 2017

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.

0reactions
jakubpawlowiczcommented, Jan 8, 2017

It turned out to work fine, save a hack to extract level 1/2 options. Merging it to master now.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found