Giter Club home page Giter Club logo

minification-benchmarks's People

Contributors

guilhermesimoes avatar johnnyfangjr avatar kush avatar privatenumber avatar renovate[bot] 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  avatar  avatar  avatar  avatar  avatar

minification-benchmarks's Issues

Add 'minify-html'

Hey there,
this package is a Rust library which comes with JS bindings - is this something you would consider adding to your benchmark?

Cheers
S1SYPHOS

latest uglify-js release appears to minify all benchmarks correctly

uglify-js supports ES6+ syntax now up to ES2020 and appears to minify the two libraries that previously failed:

$ node_modules/uglify-js/bin/uglifyjs -V
uglify-js 3.13.1

$ node_modules/uglify-js/bin/uglifyjs node_modules/d3/dist/d3.js -mc | wc -c
  267653

$ node_modules/uglify-js/bin/uglifyjs node_modules/terser/dist/bundle.min.js -mc | wc -c
  407144

Might you be able to update this benchmark to the latest release of uglify-js?

--- a/package.json
+++ b/package.json
@@ -41 +41 @@
-               "uglify-js": "^3.12.5",
+               "uglify-js": "^3.13.1",

Unfortunately I'm not running pnpm so I can't give you a PR.

Thanks in advance.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

composer
packages/minifiers/composer.json
  • tedivm/jshrink ^1.7.0
github-actions
.github/workflows/benchmark.yml
.github/workflows/lint.yml
npm
package.json
packages/artifacts/package.json
packages/bench/package.json
packages/data/package.json
packages/minifiers/package.json
  • @swc/core ^1.5.2
  • @tdewolff/minify ^2.20.19
  • babel-minify ^0.5.2
  • bun ^1.1.6
  • esbuild ^0.20.2
  • google-closure-compiler ^20240317.0.0
  • terser ^5.31.0
  • uglify-js ^3.17.4
packages/utils/package.json
nvm
.nvmrc

  • Check this box to trigger a request for Renovate to run again on this repository

strip comments

I believe the only minifier that didn't support stripping comments was esbuild, but with v0.11.15 just released, now all minifiers can strip comments.

ESbuild lags behind (non-trivially) in producing gzip friendly output for large pacakges

Thanks for publishing these benchmarks. I'm the author of bundlephobia (a tool developers use to find out minified and minzipped sizes of npm packages) and was contemplating on replacing Terser with ESBuild's minifier to shave a few seconds from build.

Seeing this benchmark, I got the picture that ESBuild and Terser and neck to neck. However, this doesn't seem to be the case for large packages. While the minified size might still be comparable in some cases, the gzipped size difference between esbuild and terser can vary between 5%-9% β€” which one might consider non-trivial difference for minification.

Benchmarks after replacing Terser with ESBuild in Bundlephobia's webpack config, and after manually extracting out license-style comments β€”

Package Minified Terser Minified ESBuild Minzip Terser Minzip ESBuild
webpack 2.48 MB 2.52 MB (+2%) 650KB 683 KB (+5%)
echarts 957 KB 975 KB (+2%) 304KB 316 KB (+4%)
antd 1.16 MB 1.27MB (+9%) 345 KB 370 KB (+7%)
victory (charts) 518 KB 532 KB (+3%) 130KB 140 KB (+8%)

The results remain the same whether running esbuild minify through esbuild-loader or the ESBuild CLI on the webpack built bundle.

Is there anyway to capture this on the current page?

Set minified output target for all tools, fix questionable results

Feature request

There's a very big difference in minifying output for a ES2018 target or a ES5 target.

This is ES2018:

var foo = 1;
var bar = 2;
{ foo, bar }

And this is ES5:

var foo = 1;
var bar = 2;
{ foo: foo, bar: bar }

Currently, not all tools are minifying to the same target. For example, Terser has the default target of ES5 while esbuild has the default target of ES2018.

This means that the current results are not accurate and do not represent what each tool can accomplish.

Alternatives

No response

Additional context

No response

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project

are github actions accurate for testing performance?

from the readme:

Benchmarks are gathered on every PR via GitHub Actions (verifiable minified artifacts are uploaded on each run)

i'd expect that because github actions has varying use throughout the day that the performance varies massively and could spike and dip at any time. it's possible this is a useful metric for other people that need to run minification fast on github actions but generally performance is more often looked into by people minifying on their own machines, whether that's during testing, a local build step before uploading to a server, or automating a build step on a personal weak server.

maybe this repository should try benchmarking on user hardware? it probably wouldn't get updates as fast but would likely be much more useful to have benchmarks done on things like raspberry pis, desktops, old laptops, etc.

stop using bina if possible

the program is extremely buggy, it couldn't install to my working directory because there were spaces in the name, and npx bina --help throws an error message despite npx bina saying to use bina --help
it also has terrible security practices, like relying on the bina.egoist.sh domain to run a shell script without any verification whatsoever, when really it should just be part of the npm package

i'm assuming bina is only used for the postinstall to install tdewolff/minify, this seems unneccecary considering minify has an npm package.
it mentions to use npm i @tdewolff/minify for javascript bindings on the github readme

Add `bun` bundler

It would be interesting to see whether bun build is capable of bundling any of the libraries and how well it does.

Time column

Quick question. Is the "Time" column on each table how long it takes the program to minify the code or how long the browser takes to parse/execute the minified code? πŸ€”

swc does not support minification yet

The option exists, but it's there because of future plan.
The only thing swc does and which is similar to minification is skipping comments and some whitespaces.

I'm porting terser to rust at swc-project/swc#1302
I think swc should be added to the list after it's implemented.

And swc.transform applies (really) lots of compatibility transforms, as swc reimplements features of babel.
I'm going to add swc.minify with the PR I mentioned, so it should be used instead of swc.transform.

Leverage caching

Feature request

Every upgrade PR doesn't need to re-benchmark everythingβ€”just the new minifier. Each minification result should be cached by minifier name, version, and output code.

Motivations

Slow GitHub Actions taking ~30min.

Alternatives

No response

Additional context

No response

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project

Refactor to benchmark with hyperfine

The "hyperfine" tool at https://github.com/sharkdp/hyperfine could be useful for abstracting benchmarking logic. To use it with minifiers lacking CLIs, we'll need to create simple CLI scripts (not difficult). In such cases, the benchmarks will include FS read, but it might have a negligible impact and lead to a fairer comparison, as all minifiers will have to read from the FS, reflecting the performance cost based on runtime choice.

Fixing the google-closure-compiler advanced mode

The ADVANCED mode of the Closure Compiler is pretty strict, and any error make it fails. You'll need to provide sufficient information about all variables used in the library to minify in order to use it.

As you can't of course do that here, one (very) ugly way to avoid failure of minification would be to set the jscomp_off flag to '*' in google-closure-compiler.advanced.js.

I tried running it and here are the results, however I didn't test each library to see if it works. What do you think about it?

πŸ“‹ Results

d3 v6.7.0

  • Unminified size: 560.0 kB
  • Unminified Gzip size: 131.4 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-54% 260.6 kB πŸ†-30% 92.8 kB πŸ† 13β€―796ms

jquery v3.6.0

  • Unminified size: 288.6 kB
  • Unminified Gzip size: 85.1 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-70% 87.4 kB πŸ†-62% 32.5 kB πŸ† 6β€―725ms

lodash v4.17.21

  • Unminified size: 544.1 kB
  • Unminified Gzip size: 97.3 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-89% 60.2 kB πŸ†-79% 20.9 kB πŸ† 7β€―491ms

moment v2.29.1

  • Unminified size: 173.9 kB
  • Unminified Gzip size: 36.5 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-72% 49.6 kB πŸ†-52% 17.6 kB πŸ† 5β€―150ms

react v17.0.2

  • Unminified size: 72.1 kB
  • Unminified Gzip size: 19.5 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-65% 25.4 kB πŸ†-52% 9.4 kB πŸ† 4β€―115ms

terser v5.7.0

  • Unminified size: 869.4 kB
  • Unminified Gzip size: 174.5 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-58% 368.9 kB πŸ†-33% 118.5 kB πŸ† 9β€―117ms

three v0.124.0

  • Unminified size: 1.2 MB
  • Unminified Gzip size: 249.0 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-58% 527.6 kB πŸ†-41% 148.5 kB πŸ† 12β€―824ms

vue v2.6.12

  • Unminified size: 223.2 kB
  • Unminified Gzip size: 62.3 kB
Minifier Minified size Minzipped size Time
google-closure-compiler.advanced πŸ†-69% 71.3 kB πŸ†-55% 28.2 kB πŸ† 5β€―966ms

annotate minified sizes relative to smallest minification

Request from @kzc:

  • Each "Time" is annotated with a multiplier relative to the fastest minifier

@privatenumber It'd be useful if both the Minified size and Minzipped size columns followed a similar methodology and showed a multiplier (or percentage) relative to the smallest value in the column. The current percentages relative to the original file and gzipped file sizes are not as useful.

For example, the minzipped size for d3 shows -33% 87.23 kB for uglify-js and -31% 90.63 kB for esbuild - a two percent spread in size relative to the original gzip size. But most users are interested in the relative size difference between the bundles to show how much they could be saving over the wire - in this case: 90.63 / 87.23 = 1.039x - nearly a 4% difference between the two minifiers: (90.63/87.23 - 1) * 100 = 3.90%.

846a888#commitcomment-55713496

Add data analysis

We used to have an analysis section but I removed it because it was unmaintained.

I'm thinking the benchmarks could also output a JSON/YAML version, and we could pass that into ChatGPT to generate an analysis that recommends a minifier for different use-cases.

It should probably live in a different GitHub Action, because generating the benchmarks is quite expensive (40 min), and we wouldn't want the action to fail due to an API error (which happens often).

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.