What's the difference between concat and uglify and minify?

ConcatenationGruntjsMinifyUglifyjs

Concatenation Problem Overview


What's the difference between concat, uglify, and minify tasks in grunt? I set up an uglify task for all of my site's javascript tasks, and it seemed to both minify and concatenate them. Grunt's site has a great description for how to configure each task, but it doesn't seem to explain what each task actually does.

Concatenation Solutions


Solution 1 - Concatenation

  • Concatenation is just appending all of the static files into one large file.

  • Minification is just removing unnecesary whitespace and redundant / optional tokens like curlys and semicolons, and can be reversed by using a linter.

  • Uglification is the act of transforming the code into an "unreadable" form, that is, renaming variables/functions to hide the original intent... It is, also, irreversable.

Solution 2 - Concatenation

Concatenation - Merges all the specified files to create a new single file.

Minification - It simply means all the unnecessary white spaces and redundant optional tokens will be removed.

Example - self.description = 'Hello'
Minified version will be - self.description='Hello'

Uglification - It simply means converting the code in such a format that core logic can't be understand easily. To do the same it renames the variable and their references, it renames the parameter with shorter name etc.It simply obfuscate the business logic so that no one can easily understands it.

Example -

self.description = 'Hello';
function(self.description){}

Uglified version will be -

  j.description = 'Hello';
  function(j.description){}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmheaversView Question on Stackoverflow
Solution 1 - ConcatenationdiclophisView Answer on Stackoverflow
Solution 2 - ConcatenationGaurav TiwariView Answer on Stackoverflow