Monday, May 20, 2024
66
rated 0 times [  67] [ 1]  / answers: 1 / hits: 29913  / 13 Years ago, thu, september 29, 2011, 12:00:00

I have seen people put all their JS code into one single line. (something like this: http://www.drasticdata.nl/DrasticTreemap/Examples/js/swfobject.js) I know they are trying to protect their IP. But I want to read the code and study it.



Is there a way to make those one-line code readable? For example, break it down to multiple lines?



Thanks.


More From » coding-style

 Answers
75

A quick google search for JavaScript de-obfuscator will return you multiple online parsers that format obfuscated code into something formatted and readable.



The following works pretty well:



http://jsbeautifier.org/



There is no way to rename variable names to their, once semantic, forms. Something you'll have to tread through...



A couple of terms to note minification and obfuscation:



Minification (Wikipedia)




Minification (also minimisation or minimization), in computer
programming languages and especially JavaScript, is the process of
removing all unnecessary characters from source code, without changing
its functionality.




Obfuscation (Wikipedia)




Obfuscated code is source or machine code that has been made difficult
to understand for humans. Programmers may deliberately obfuscate code
to conceal its purpose (security through obscurity) or its logic to
prevent tampering, deter reverse engineering, or as a puzzle or
recreational challenge for someone reading the source code. Programs
known as obfuscators transform readable code into obfuscated code
using various techniques.




References



http://en.wikipedia.org/wiki/Obfuscated_code



http://en.wikipedia.org/wiki/Minification_(programming)


[#89853] Wednesday, September 28, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
travion

Total Points: 137
Total Questions: 96
Total Answers: 103

Location: India
Member since Wed, Aug 4, 2021
3 Years ago
travion questions
Mon, Dec 16, 19, 00:00, 5 Years ago
Sat, Oct 19, 19, 00:00, 5 Years ago
Fri, Sep 20, 19, 00:00, 5 Years ago
Wed, Nov 14, 18, 00:00, 6 Years ago
Sun, Oct 28, 18, 00:00, 6 Years ago
;