Patu Digua, or shortly Digua, is a web (HTML, JavaScript and CSS) obfuscator and compressor. It will reduce the size of your website, boosting performance this way, and it will make your JavaScript source code harder to be copied.
The question is why to use such a program. Why to obfuscate your website? First of all maybe you really don’t want somebody to copy your JavaScript code as it is business critical. Of course, this is not like the code will be compiled and linked, only harder to read and understand. And for this you should definitely use the obfuscation for JavaScript variables and functions.
But this is not the only reason to use this program. The compression of the web code is what I think is really matters. Less code means faster websites.
Patu digua is the smallest known spider in the world.
How is the obfuscation and compression done by Patu Digua? Basically a root folder for your site is provided and this will be the source. The destination will be the processed file/folder structure for your site. Every file in the source folder will be processed recursively.
For HTML files (names ending with *.html and *.htm) unnecessary whitespaces and comments are removed. Because in some tags, like PRE and XMP, whitespaces are relevant those are maintained in there. SCRIPT and STYLE tags are processed like JavaScript, respectively CSS files. HTML IDs (specified in the id or for attribute) and CSS classes (specified in class attribute) are translated/obfuscated.
For JavaScript files (names ending with *.js) unnecessary whitespaces and comments are removed. The global and local variables, labels and functions are translated/obfuscated.
For CSS files (names ending with *.css) unnecessary whitespaces and comments are removed. The HTML IDs (selector starting with hash(#)) and CSS classes (selector starting with dot(.)) are translated/obfuscated.
An entity, like an HTML ID, CSS class or JavaScript variable is translated/obfuscated as follows. For every entity a new name is generated, basically composed by a prefix and a random or sequentially generated number between a given range(let’s say 1000 and 9999). If for HTML IDs we specify ‘i’ as the prefix, then a possible generated name will be i5478 or i4592. Every occurrence of that entity will be replaced with the new name. All the pairs (old name = new name) will be saved into a translation file for future use. So if you translate portions of a website then it would make sense to obfuscate using the same names. Patu Digua offers the possibility to ignore some entities from the obfuscation process.
The files that are not processed, like images, are simply copied from source to destination. Other files, like temporary ones, are simply ignored and skipped in the process.
Patu Digua can be used
Patu digua can be run from the command line interface. The command line interface options are the following:
Patu digua can be easily integrated in your Java program. And it takes only one line of code:
new Digua(“/path/to/config.file”).run();
It will load the specified configuration file and it will run the entire compression/obfuscation. If you want to specify another source directory/file than the one in the configuration file:
XProperties options = new XProperties(); options.load(“/path/to/config.file”); options.put(“src”, “/path/to/source.file”); Digua digua = new Digua(options); digua.run();
In the same way you can specify other options too. For detailed specification please consult the Configuration section. The entire process can be run in a separate thread:
new Thread(new Digua(“/path/to/config.file”)).start();
The graphical interface offers you the possibility to easily modify a configuration file and start the compression/obfuscation process. It has two modes of operation: normal and drop zone. In normal you can specify the options as in any other program. The drop zone is a box (that usually sits always on top) and where you can drag and drop directories and files that they will be automatically processed according to the options specified in normal mode.
All the configuration options that are specified in the configuration files are described like properties.
Check out this configuration file, where every property has a comment before to explain it in detail. Such a configuration file can be found in the distribution too.
Patu Digua is written in Java and heavily based on ANTLR. The user interface is designed in Swing and the command line interface is using Commons CLI.
You can easily build Patu Digua from the sources. For this you have to retrieve the sources from Subversion and follow the next steps
If you are a developer, designer or tester then you can help Patu Digua development in many ways:
Just use the forum and post there how do you want to help Patu Digua development.
You can also DONATE to the project.
Downloads | Project summary page @ SourceForge | Forum | Bug Reports and Feature Requests