Coder Social home page Coder Social logo

goalsmashers / css-minification-benchmark Goto Github PK

View Code? Open in Web Editor NEW
338.0 15.0 37.0 2.52 MB

A comparison of CSS minifiers for node.js

Home Page: https://goalsmashers.github.io/css-minification-benchmark/

License: MIT License

JavaScript 0.57% CSS 99.43%

css-minification-benchmark's Introduction

Build Status

What is css-minification-benchmark?

A comparison of CSS minification engines.

FAQ

Which engines are covered?

How can I see the results?

Clone the repository, install the dependencies with npm install and then run node ./bin/bench.js. That's it!

If you prefer to see results without cloning the repo here are the most recent ones.

How can I generate the html report?

Just run node ./bin/bench.js --html > report.html

How can I test my CSS file?

Just copy your file to the data directory (make sure the filename ends with .css) and re-run the benchmark.

How can I add a new minifier to the list?

  • add it to package.json as a devDependency
  • run npm install
  • require it in lib/minify.js and add it to minifiers hash
  • run npm run bench
  • add it to this file in "Which engines are covered?" section above
  • send a PR (if you wish to have it included)

How can I compare a subset of minifiers?

Just run node ./bin/bench.js --only csso,cssnano (it's turned into /.*(csso|cssnano).*/ regex)

Can I get the compressed gzip size as well?

Run node ./bin/bench.js --gzip to measure the gzip size instead of the regular file size.

License

css-minification-benchmark is released under the MIT License.

css-minification-benchmark's People

Contributors

alexander-akait avatar army8735 avatar ben-eb avatar denji avatar dependabot[bot] avatar diegourban avatar dominikg avatar herrernst avatar jakubpawlowicz avatar lahmatiy avatar ludofischer avatar marek-saji avatar martijncuppens avatar nicolasbadia avatar onigoetz avatar semigradsky avatar shinnn avatar tavriaforever avatar xhmikosr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

css-minification-benchmark's Issues

New CSS minifier: miniMinifier

Hello, I'd like to add my css minifier to the list, but sadly it's not node based. it's just an experiment (I tried to make a minifier as short as possible), but it has very interesting results:

given a string to minify "str", just run:

for(i=9;i--;)str=str.replace(/^\s|\s$|\/\*[^]*?\*\/|\s*;*([^\:\w.#\x27"\s*-])\s*|(:) /g,"$1$2")

(removes comments, whitespaces and semicolons)

or a little more complete:

for(i=9;i--;)str=str.replace(/([^#\d\w\(._\x27"-])((0)[a-z%]+|0(\.))|^\s|\s$|\/\*[^]*?\*\/|\s*;*([^\:\w.#)\x27"\s*-])\s*|\s(\))|(:) |[^}]*{}/gi,"$1$3$4$5$6$7").replace(/rgb\((\d+),(\d+),(\d+)\)|#[a-f0-9]{6}/gi,function(a,c,d,b){if(b)for(i in a="#",p=[c,d,b])a+=("0"+parseInt(p[i]).toString(16)).slice(-2);return(p=a[2]+a[4]+a[6])==a[1]+a[3]+a[5]?"#"+p:a})

(removes comments, whitespaces and semicolons, leading zeros, units after zero, empty rules, converts rgb colors to hex and preserve ie8 compatibility)

You'll find more info, demo and test files on: http://xem.github.io/miniMinifier/css/

If someone can help me convert this / those functions in node, that would be very nice.
(I don't know how to do it yet ^^)

Thanks!

Clean up data used

@GoalSmashers: using already minified CSS like facebook, youtube etc doesn't show the real improvements.

I suggest we remove those and add better cases in their place.

--total overflow table

In some tests --total undefined:
      activeMinifiers.forEach(function(minifier) {
        minifier.total = storage.total(minifier.name);
      });

total_table_overflow

Add date to the test page

It would be good to know at which date the tests were created.
Right now I have no way to actually know if he comparison table was made far in the past or recently, because It is very tedious to track down each package version and compare it to the the benchmark's one. This will provide a very basic way to know if the tests are still relevant or not.

Add info below table

E.g. I think that most grunt-contrib-cssmin users don't know that it uses clean-css. It would make sense to provide this and related info below the table, so that visitors can have an immediate (broad) understanding of in which projects these minifiers are used.

Respect the OS line endings

results.html always has LF line endings which is causing issues on Windows.

Can't we use writeFileSync or something similar to write results.html?

update cssnano to 3.2.0

Being built on postcss, I'm guessing that this library will get faster/better and would like to keep track of its performance progress.

Move index.html into docs

@jakubpawlowicz I'll make a PR but you will need to change the repo setting to use the master/docs folder.

Then I will add a .nojekyll file and this way we separate code and docs. The default branch should be master then, and gh-pages can be deleted.

I'll make a PR and ping you to make the changes

Add compilation duration

It would be great to have the compilation duration too.
We could have big differences there...

Save results to an external file

I think we should improve the data generation and not generate the index.html file directly.

A few ideas for implementation:

  1. Use XHR and load the bench data
  2. Inline the data via Jekyll includes; maybe in an array or something

Either way, this should allow us to do more on the frontend part, add a GitHub ribbon maybe, add more info about the system the bench last run, add the gzip bench too and so on.

Create a gh-pages for the results

Since GitHub has this very useful feature, I think we should use it in this case.

It should be pretty easy to set up things; just rename the master branch to gh-pages.

Or alternatively, we could make a gh-pages branch in clean-css' repository. I think this makes more sense and there isn't any need for a separate repository.

What do you think @GoalSmashers?

Normalize data

Restore the data files to their original state without touching any comments.

Mention in readme that we use the default options and as such some optimizers might keep the comments some not. Alternatively, we should keep only the important comments in clean-css which should match what csso, cssnano and csswring do by default. I'm leaning towards the second solution.

/CC @jakubpawlowicz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.