mediawiki-extensions-Popups/doc/adr/0008-enable-minification-of-bundle-with-uglifyjs.md
joakin 937651f0ea Docs: Add ADR about using webpack's production mode and UglifyJS
Bug: T160061
Change-Id: I458fd6479860b3fd2a43ee382a0219743fca865d
2017-05-12 18:12:30 +02:00

1.4 KiB

8. Enable minification of bundle with UglifyJS

Date: 12/05/2017

Status

Accepted

Context

Sources are currently minified by JSMin producing a bundle bigger than necessary. We want to produce a JS bundle as small as possible to ship less code to clients.

Given we have a pre-compilation step in Popups, we can leverage node based tooling without penalty, so using UglifyJS to minify the code is an option.

We performed some analysis to see the differences in asset size between the two tools. See:

Results with the current codebase as of today 12th of May 2017 are that uglify produces a 40% smaller bundle, and a 25% smaller bundle when using gzip.

This results are stable through the last 3 months, the same test has been performed multiple times. See Compressed JS comparison

Decision

Webpack's production mode has been enabled for npm run build, and thus the compiled bundle will be minified in production with UglifyJS.

See Enable production settings for the production bundle

Consequences

The Popups bundle served in production is 40% smaller, 25% when using GZIP.