What is the difference between minification and obfuscation?
If you’re just becoming familiar with Javascript, then you have probably come across two terms – minification and obfuscation – and you may not be sure what exactly is the difference between the two terms.
The goal of minification is to improve performance
Javascript minification is a process in which Javascript files are modified (by a program that is called a “minifier”) by removing all unnecessary characters in the file. This makes the Javascript file much “lighter” (since it now contains less characters), which means that browsers can then download and process the file much faster. So, the goal with minification is to improve performance. You can also read more about minification in Javascript here: Javascript Minification.
The goal of obfuscation is to try to hide your original source code from other people
Obfuscation in Javascript is also a process in which Javascript files are modified. But, in obfuscation, the files are modified to deliberately make them difficult to understand and read. The goal is to make it so that people can not reverse engineer Javascript source code and use it for their own projects, or whatever else. But, if someone is determined enough they can and will reverse engineer any obfuscated Javascript code so that they can see the original source code – obfuscation will just slow them down a bit. Remember that browsers have to be able to translate the obfuscated Javascript source code to it’s original form so that they can understand it. And if browsers can do it, then any individual can also do it with some effort.
Obfuscation vs Minification
Hopefully now you see that although obfuscation and minification both modify the Javascript source code, they both try to accomplish two very different things. And, that is the key difference.