8

I often see something like "uncompressed for development / minified for production" when reading blogs or downloading frameworks. What is the real difference between the two, and if minified is "good for production" why is it not recommended for development?

1
  • Did you open the files in an editor?
    – Reactgular
    Mar 17 '14 at 0:05
15

Minification isn't compression in the classic sense. It refers to the removal of whitespace and other nonessential characters like comments so that the code is still valid but as compact as possible. It's effectively a form of code obfuscation.

As such, it is not recommended for development because it makes the code much less readable and much harder to edit.

Compressed code would have to be uncompressed first before execution. Minified code is still valid code in all respects and can be run immediately.

Minification happens anyway as part of the compilation process in most languages. By pre-minifying the files, you simply speed up the download and parsing process by a certain amount.

3

For different concerns.

For development you want to be able to view source and see all the details. You don't care about size much as it's often local anyway. When problems arise you want to be able to view the browser source of the actual css to see if there's any issues but this means keeping whitespace, formatting duplication, etc. When you want to try a small change in the browser itself its much easier to do in the browser source with unminified code.

For production you care more about the size, download speeds and number of http requests for real users so compressing and minifying is appropriate there. You might also want to obscure your files more from casual browsing.

2

Minification, as the name suggests, aims at creating the smallest (as number of symbols) possible version of a program that is still in the form of a source code. Minification is not only an obfuscation, but it usually "minifies" parsing (and as a whole - compilation) time: https://stackoverflow.com/a/1181459/880114.

Compression (specifically in the web, gzip is usually used) is simply archiving files in smaller size so requests for their transfer can take a lesser time. Still there is a decompression on the client side and this might not always be the way to go.

-2

“Minified” are compressed versions of the original files. Most of the compression is achieved by eliminating whitespace and changing variable names to shorter character lengths. For this reason, minified versions are great for deployment in final builds while the more human readable, non-minified versions are best used in production – where you, the developer, may want to look up particular code elements.

2
  • this doesn't seem to offer anything substantial over points made and explained in prior answers
    – gnat
    Dec 31 '17 at 4:50
  • the word compressed here is wrong, compression is a different thing
    – user102446
    Jan 15 '18 at 11:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.