mediawiki-extensions-Popups/docs/adr/0008-enable-minification-of-bundle-with-uglifyjs.md
Thiemo Kreuz 7ef925fb97 Prefer YYYY-MM-DD ISO dates in all documentation
It is probably not that critical to understand if "09/11/2016" refers
to September 11th or November 9th. I still think it's worth looking for
a documentation format that is easy to understand by an international
developers community. My personal best practice is to use the ISO format.

Change-Id: Ib209a8a1651970d74f82c188ae4b84d1a4eb534e
2019-01-17 17:11:29 +01:00

1.4 KiB

8. Enable minification of bundle with UglifyJS

Date: 2017-05-12

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.