Frage

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.

War es hilfreich?

Lösung

  • 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.

Andere Tipps

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){}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top