Javascript: Minification vs Obfuscation

Minification:

Comments and extra spaces are removed
Provides short names for variables and functions
Removes unwanted variables

Uses:

Reduce file size intern reduces load times
Improves site speed and accessibility
Can be accessed with low bandwi…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Kurapati Mahesh

Minification:

  1. Comments and extra spaces are removed
  2. Provides short names for variables and functions
  3. Removes unwanted variables

Uses:

  1. Reduce file size intern reduces load times
  2. Improves site speed and accessibility
  3. Can be accessed with low bandwidth network

// Sample javascript file
function print() {
console.log('Hello World!');
}
print();

It's minified version is:

function print(){console.log("Hello World!")}print();

Obfuscation:

  1. Business logic is not exposed
  2. Obfuscated isn't readable hence copying and reusing is not possible.
  3. It prevents vulnerable attackes

For the above same code snippet's obfuscated version is:

(function(_0x42a639,_0x56f39){var _0x3177f0=_0x3dc6,_0x3ad656=_0x42a639();while(!![]){try{var _0x39f7cb=-parseInt(_0x3177f0(0x175))/0x1+parseInt(_0x3177f0(0x179))/0x2*(parseInt(_0x3177f0(0x174))/0x3)+-parseInt(_0x3177f0(0x17b))/0x4+parseInt(_0x3177f0(0x176))/0x5+-parseInt(_0x3177f0(0x177))/0x6+-parseInt(_0x3177f0(0x17c))/0x7+parseInt(_0x3177f0(0x173))/0x8;if(_0x39f7cb===_0x56f39)break;else _0x3ad656['push'](_0x3ad656['shift']());}catch(_0x246c48){_0x3ad656['push'](_0x3ad656['shift']());}}}(_0x43bd,0x1c675));function _0x43bd(){var _0x35b3fa=['123SaKLEH','12398znBZem','102425JTqbPj','190338WWUPVw','Hellow\x20World!','1292MJSgQk','log','527404lCUqJG','63973dQqvvq','2035848dPkEIA'];_0x43bd=function(){return _0x35b3fa;};return _0x43bd();}function _0x3dc6(_0xf65f24,_0x5eeff0){var _0x43bdd9=_0x43bd();return _0x3dc6=function(_0x3dc6f1,_0x485198){_0x3dc6f1=_0x3dc6f1-0x173;var _0x3d72ac=_0x43bdd9[_0x3dc6f1];return _0x3d72ac;},_0x3dc6(_0xf65f24,_0x5eeff0);}function print(){var _0xd7f32d=_0x3dc6;console[_0xd7f32d(0x17a)](_0xd7f32d(0x178));}print();


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Kurapati Mahesh


Print Share Comment Cite Upload Translate Updates
APA

Kurapati Mahesh | Sciencx (2022-10-24T09:46:37+00:00) Javascript: Minification vs Obfuscation. Retrieved from https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/

MLA
" » Javascript: Minification vs Obfuscation." Kurapati Mahesh | Sciencx - Monday October 24, 2022, https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/
HARVARD
Kurapati Mahesh | Sciencx Monday October 24, 2022 » Javascript: Minification vs Obfuscation., viewed ,<https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/>
VANCOUVER
Kurapati Mahesh | Sciencx - » Javascript: Minification vs Obfuscation. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/
CHICAGO
" » Javascript: Minification vs Obfuscation." Kurapati Mahesh | Sciencx - Accessed . https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/
IEEE
" » Javascript: Minification vs Obfuscation." Kurapati Mahesh | Sciencx [Online]. Available: https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/. [Accessed: ]
rf:citation
» Javascript: Minification vs Obfuscation | Kurapati Mahesh | Sciencx | https://www.scien.cx/2022/10/24/javascript-minification-vs-obfuscation/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.