Question

I am learning jQuery and I am writing a jQuery plugin and would be happy to share with others (off-course those who want) when completed. I recently learned that obfuscation would help me with securing the code as well as making it light-weight. But I also found that obfuscated JS is often used to insert malicious code. As I am not intending to have any malicious code in my plugin will it effect in people trusting my code to at least try-out if I obfuscate it? My main idea to use obfuscation is to disallow any edits to code so that my plugin would keep on working as intended. And I beleive obfuscation would help me in that.

Thanks

Was it helpful?

Solution

The general consensus with jQuery plugins is to release two versions. The original, uncompressed code, and then another minified version. Indeed, this is the approach that the authors of the jQuery library themselves have adopted, for example:

Uncompressed > http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js
Minified > http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

You should know the difference between the two terms minified and obfuscated, but generally:

Minification:

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. These unnecessary characters usually include white space characters, new line characters, comments, and sometimes block delimiters, which are used to add readability to the code but are not required for it to execute.

Obfuscation:

In software development, obfuscation is the deliberate act of creating obfuscated code, i.e. source or machine code that is difficult for humans to understand. Programmers may deliberately obfuscate code to conceal its purpose (security through obscurity) or its logic, in order to prevent tampering, deter reverse engi neering, or as a puzzle or recreational challenge for someone reading the source code.

So in short, minification != obfuscation. The idea of releasing a minified version is to reduce the filesize, and this can often be achieved using a combination of minification and onfuscation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top