Difference between Minification and Obfuscation

Key Difference:  Obfuscation and minification are two commonly used terms in programming, especially in JavaScript programming. Minification defines a process by which the files are modified by removing all unnecessary characters in the files. This process makes the files lighter, and thus helps in improving the performance. On the other hand, Obfuscation is the process of modifying files in a manner that they become unreadable. It prevents the reuse of source code by unauthorized entities.

Obfuscation and minification are two commonly used terms in programming, especially in JavaScript programming. In programming, minification refers to a technique by which unnecessary characters are removed from the source code, while keeping the same functionality as before the process of minification. On the other hand, obfuscation refers to the modification of the files in a way that it becomes difficult to read and understand them. Thus, both have different goals to achieve.

Minification defines a process by which the files are modified by removing all unnecessary characters in the files. This process makes the files lighter, and thus helps in improving the performance. These files are loaded on browses in lesser time. However, it is important to keep the functionality of the input file unchanged. In many of the larger projects, minification is kept in integration with the build process.

This process is generally done by parsing code and later outputting it again in a compressed form. The code usually remains unreadable with naked eyes. It removes all the unnecessary code like white spaces, comments and new line characters. Apart from getting a smaller file, the process also checks the validity of the code, as the invalid code is not parsed and minified properly.

Obfuscation is the process of modifying files in a manner that they become unreadable. It prevents the reuse of source code by unauthorized entities. However, there are chances of reverse engineering or de-obfuscating the code. In order to understand the obfuscated code, the browser must be able to translate the obfuscated JavaScript source code to its original form. Like minification, it also removes comments and white spaces. However, it also leads to munging of the code. Functions and variable names are generally converted into smaller strings. This leads to reduction in the size of code and also the code becomes harder to understand.

Obfuscation and minification, both are processes of modifying source code like JavaScript. However, they both differ primarily in their goals. Minification is done for improving performance of the code. On the other hand, obfuscation is done to make the source code difficult and unreadable, in order to hide the original source code. There are various tools for obfuscation and minification.

The process of minification is comparatively simple and also there are less chances of generating any of the bugs as compared to obfuscation. Obfuscation may also increase the difficulty level of debugging the code during production.

Comparison between Minification and Obfuscation:

 

Minification

Obfuscation

Definitions

Minification refers to a technique by which unnecessary characters are removed from the source code, while keeping the same functionality as before the process of minification

Obfuscation is the process of modifying files in a manner that they become unreadable and difficult to understand.

Goal

Improving performance

Hiding source code

Methods

Like removing of white space characters, new line characters, comments, and sometimes block delimiters

Like changing the names of variables, functions, and members, making the program much harder to understand

Examples of tools used

JSMin and YUI Compressor.

Dojo Compressor

Process

Simple

Comparatively complex

Risk and maintainability

Comparatively less

Comparatively more

Image Courtesy: minifycss.com, weblogs.asp.net

Most Searched in Arts and Humanities Most Searched in Environment
Most Searched in Home and Garden Most Searched Non-Alcoholic Drinks
HTML5 vs PHP
Web Hosting vs Web Publishing
Hyundai i20 vs Maruti Suzuki Swift
Nokia Lumia 925 vs iPhone 5

Add new comment

Plain text

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.