Skip to main

Minification

Pronounced
min-if-i-KAY-shun

Minification is a way of making a site faster by automatically shrinking the size of its HTML, CSS and JavaScript files.

When developers write code, they try to keep it readable — that is, easy to scan and to understand. Good ones do, at any rate.

To that end they follow a code style guide, a different one for each language. Those conventions call for generous use of spaces to indent blocks of code, for comments, and for a number of other habits that make the code easier on the eye.

None of that is needed for the site to run. In most cases you can strip out every surplus space and line break, turn the whole file into one long unbroken line, and it will keep working exactly as before — only now the files weigh less and the site loads faster.

The Bootstrap CSS bundle, for example, shrinks by 20–25% under automatic minification.

Files in that state are painful for a developer to work with, so minification is normally done as part of deployment — at the moment the site is moved onto its production hosting, and not before.