This site is dedicated to providing a collection of useful tools for those that want to develop JavaScript applications.
Currently the following tools are available:
A JavaScript Tester is a useful tool for trying out small bits of code. It especially useful in analyzing complex
RegExp statements where the results are not always obvious.
A JavaScript Validator can help eliminate a number of bugs before you begin testing. It is based on Douglas Crockford
JSLint program (www.JSLint.com) but is less restrictive. For example, a single statement following an "if" statement does not have to be enclosed in brackets.
A JavaScript Formatter can be a very useful tool to help you analyze your code. It will insure that all statements are consistently indented.
A JavaScript Obfuscator can make it more difficult for other to plagiarize your code. While a hacker can crack even assembler/machine code,
you may want to make his life as difficult as possible with this program. An added benefit is that it will usually reduce the size of your
code and potentially improve performance.
A JavaScript Compactor can reduce the size of your JavaScript code and can reduce download times substantially.
The compactor can identify statements missing a semicolon and handle these situations which can cause problems with other compactors.
A batch program that can be run from the command line to combine JavaScript files and then validate, obfuscate, compact and/or compress
the input files
A JavaScript based compression program can reduce the size of your code by up to 75%. The compression process is slow
but the decompression is very fast. In large JavaScript programs, it can save substantial time in downloads and space on servers.
If you download this web page, it's associated files,
you may use the batch facilities to automate your build processes. If you are using Netscape or Firefox browser, an additional tab on the web page will be displayed that will allow you
to read and write files from your local hard drive.
Feedback is welcome. We wish to make this the best JavaScript site on the web.
Input area for JavaScript
Message Area:
Ready
Input area for JavaScript or JavaScript in HTML
Message Area:
Ready
Results:
Input / Output area for JavaScript code
Formatting Options
Indent Style:
Matching right and left indents
Hanging left bracket
Indent Amount:
Line Length:
Replace missing semicolons
Blank line between functions
Message Area:
Ready
Input / Output area for JavaScript code
Compacting Options
Missing semicolons in JavaScript:
Add missing semicolon only when necessary
Leave new line in code
Leave new line and comment in code
Remove unnecessary semicolons
Message Area:
Ready
Obfuscation - Setup and Planning
If care is not taken in the setup and planning phase for obfuscation, the resulting code may not work.
You should combine multiple script files into a single script file before obfuscation to insure that the obfuscated variable names in one script
do not conflict with obfuscated variable names in other scripts. For example, a global variable in one script may be given the obfuscated name of "aA"
and a global variable in another script may be given that same name if they are obfuscated separately. If the two files are combined, they will be given
unique names that will not conflict.
This obfuscation program can obfuscate all identifiers (variable, functions and object names, methods and properties):
If "Obfuscate Defined Global Variables" option is selected, defined global variable are obfuscated.
Implied global variables (any variable that is not defined with a var or function statement) are never obfuscated.
If "Obfuscate Object Members" option is selected, the following objects, methods and properties are excluded:
System objects, methods and properties. An attempt has been made to exclude all objects, methods and properties of JavaScript built-in objects and functions.
Browser objects, methods and properties. An attempt has been made to exclude all commonly used objects, methods and properties used by browsers (DOM).
Object members using string notation An object member name in the form of object['name'] are excluded from obfuscation.
Identifiers within 'with' statements An attempt has been made to exclude identifiers used within 'with' statements
because the scope of a 'with' statement can only be determined at run time. It's best to avoid 'with' statements altogether.
For a list of objects and members explicitly excluded from obfuscation, click here
If you exclude all global variables and object members from obfuscation, obfuscation should always work regardless of any 'string expressions'
or other script files used. However if you select to obfuscate global variables and object members,
you must identify and manually exclude all variables and functions that are evaluated
as strings by JavaScript ('string expressions'), such as strings used in
HTML event handlers, eval, setTimeout and setInterval statements.
This obfuscation program does not attempt to analyse these statements string variables. The recommended approach
is to pass functions by reference
and avoid any statements that are evaluated as strings. However, these 'string expression' variables and functions
identifiers may be excluded from obfuscation by adding comment lines to your source code.
The comment line format for excluding identifiers is:
//obfuscate exclude identifier {, identifier ...} where identifier is either a javascript variable,
function, object or object member. //obfuscate excludeMembersOf identifier] , identifier ...} where identifier is the name of a javascript object
you wish to exclude along with all of its members from obfuscation.
Variables and objects in other JavaScript files will also need to be manually excluded.
You may also decide to obfuscate your string variables in your javascript program. It makes it more difficult for someone to easily follow your code.
The performance impact should be minimal. You can also obfuscate 'if' statements, for example 'if (a==3) {b=4; c=3;} else d=4;' would be converted to '(a==3)?(b=4,c=3):d=4;'.
It is a good practice to check your code using the validation program, test and debug your code before obfuscation.
Then test your obfuscated code in steps. It's best to begin by testing
your code without obfuscating global variables and object members or obfuscating strings since it will be easier to identify any problems. After
you complete this step, try obfuscating global variables and then object members and when successful, then compact and compress your code.
JSUtility supports batch operation that can be used to:
validate code and check it into a production folder,
combine JavaScript files for testing,
combine JavaScript files for obfuscation, compaction and/or compression.
The necessary files are included in the download
from this web site and are contained in the "Sample Batch" folder.
The batch operations are dependent upon CScript command provided as part of Microsoft Windows.
A sample batch file is provided called "factorial_test_build.bat" that executes "CScript factorial_test_build.wsf" in the
batch script. The file "factorial_test_build.wsf provides the necessry data to run JSUtility in batch mode.
The key inputs are:
a list of input files to be included,
the options for obfuscation, compaction and compression,
the destination file name for the output of the operations,
the html file name for reports, and
the list of operations to be performed.
Please use this sample wsf file as a model for creating your own batch operatiosn.
Contact Information
Patrick
J.
O'Neil and Associates can be contacted by:
E-Mail:
US
Mail: Patrick J. O'Neil 68 Seth Low Mountain Road Ridgefield, CT
06877 USA