Experimental JavaScript bundler and minifier uses Go for speed

Share
  • February 18, 2020

JavaScript bundling involves separating files to reduce the number and size of server requests that are needed to load a web page. There are a number of build tools for JavaScript out there. Between webpack, Gulp, and parcel, the ecosystem is packed with choices.

A new JS bundler and minifier is available as an experimental hobby project, but there’s something a little different about esbuild. With the help of Golang, it’s much faster than the rest.

Let’s take a quick tour of this JS tool as well a look forward to what’s on the agenda for webpack.

SEE ALSO: Mint programming language is an alternative to JavaScript for writing single page apps

Speedy performance

According to benchmarks, esbuild is 10 to 100 times faster than other commonly used JavaScript bundlers including webpack, rollup, and parcel, with roughly the same output size. (Test out the benchmark using make bench-three.)

Let the numbers speak for themselves:

javascript

Benchmarks for esbuild. Source.

The key to esbuild’s speed lies in its language of choice; it is written in Go. Since Go is such a speedy language, it allows this bundler to take advantage of that and avoids slowdown.

According to its README, it currently supports:

  • CommonJS modules
  • ES6 modules
  • Bundling with static binding of ES6 modules using --bundle
  • Full minification with --minify (whitespace, identifiers, and mangling)
  • Full source map support when --sourcemap is enabled
  • JSX-to-JavaScript conversion for .jsx files
  • Compile-time identifier substitutions via --define
  • Path substitution using the browser field in package.json
  • Automatic detection of baseUrl in tsconfig.json

Source : JAXenter