Giter VIP home page Giter VIP logo

Comments (2)

evanw avatar evanw commented on April 28, 2024

Cool! Thanks for posting about this. It looks really well-considered.

I took a brief stab at hooking up esbuild and it worked fine on the first try (including passing the todomvc tests). Here's how to invoke it:

{
  id: 'esbuild',
  name: "esbuild",
  variants: [
    {
      command: 'esbuild %%in%% --minify-whitespace --outfile=%%out%%'
    },
    {
      id: 'minify',
      command: 'esbuild %%in%% --minify --outfile=%%out%%'
    }
  ]
},

Running the benchmark on my machine looks like this:

It's not surprising that the size of esbuild's minified output isn't completely as small as other minifiers that have been carefully tuned for years. I only did enough minification in esbuild to bring it within the same ballpark of other minifiers. Only the most significant minification transformations are implemented, and I haven't yet optimized specifically for small size under compression.

It's also not surprising that esbuild is the fastest, especially given the overhead of JIT warmup in node. Much of esbuild's performance comes from parsing multiple files in parallel, but esbuild also has fast single-threaded performance.

Some thoughts about performance/correctness tests:

  • I've noticed that running a minifier is much slower the first time. I assume this has to do with the OS loading the files from disk into some cache. When benchmarking minifiers, make sure to run the multiple times and discard the first result, or the first minifier will be unfairly penalized.

  • Even if a code base doesn't have tests, I've gotten some mileage out of just executing the code and making sure it doesn't crash on startup. Presumably this type of test only works for library code and not application code.

  • JavaScript has a great test suite called test262. It's not specifically intended for minifiers but it has a ton of coverage for various strange language feature combinations and has helped me find a ton of bugs. For example, you can minify each valid syntax test case and re-parse it with another parser to check that it's valid syntax. You could also do a whitespace-only minification and then verify that the syntax tree is the same using another parser. If you're ambitious enough you could even try running the tests although you'll need to figure out a test harness.

I do think this project would be useful for me. The more tests the better! And it's great to have a nice visualization like this. I've been manually entering numbers into a Google spreadsheet.

from esbuild.

evanw avatar evanw commented on April 28, 2024

I'm going to close this since it's a conversation and not an issue with esbuild. Please feel free to continue to discuss this here though!

from esbuild.

Related Issues (20)

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.