Not "Compile your code by hand"! Remember that "programs should be written for people to read, and just by chance for machines to run."
The reason why people use Javascript mini-protectors (or obfuscators) is precisely because this manual work is unnecessary, repetitive and subject to errors:
- Your code gets harder to read;
- Your code gets harder to debug (when seeing an error message, it is harder to locate it in the sources);
- Simple errors (such as exemplified by Sergio in the comments), that would be immediately visible in a "clean" code could go unnoticed in a code that uses many such tricks.
- Often the process of minimizing code is "donkey" (e.g., exchanging all variables of many letters for variables of one letter), so it is better to delegate this task to a tool than to do it yourself.
- And, in addition, this tool can do things that you wouldn’t think of doing in the original source code (e.g.: remove all line breaks and indentations).
- And in the end, most webservers compresses contents (using gzip or deflate) before sending to customers, so that even the gains from minification do not seem to me be so great when it is supposed (opinion; I have no concrete facts to serve as a basis).
For these reasons, it is not recommended to make this type of change directly in the sources if its only reason is to decrease the size. Keep your code clear and clean, and let other programs "enfeie" you for you.
P.S. You also mention 'making them more "secret," which I understood as an attempt to "protect the source code," right? If so, I suggest you read that my answer to a related question. Many people use blinders not for their original purpose of obfuscation, but because they perform better in the sense of reducing code size percentage.
My suggestion is to even use a library that does this. Doing it by hand is risky, it can give errors. There are many details to take into account like
true === 1 // false
.– Sergio
If for you the fact
!0
result infalse
is something secret, you need to review your concepts.– Oralista de Sistemas
not everyone knows it @Renan ..
– Iago Bruno