Login Register

JS Linker in Dojo

The JS Linker was just committed to the Dojo repository. From the Linker's readme file: The JavaScript source code can be represented in different levels of granularity. The JavaScript Linker uses the Abstract Syntax Trees (ASTs) representation, which represents the lowest level of detail, to model the source code. One of the main task for this project was to write a JavaCC compatible grammar that strictly follows the ECMA Specification. JavaCC uses this grammar to build a custom parser than can read and analyze the JavaScript source, which in turn, is used to build the JavaScript Linker. The purpose of JavaScript Linker is to process HTML/JavaScript code base to prepare code for deployment by reducing file size, create source code documentation, obfuscate source code to protect intellectual property, and help gather source code metrics for source code analysis & improvements. The source code modifications can either be made in place by overwriting the input files, or can be saved to a user-specified output directory. This latest alpha release of the JavaScript Linker uses the new ECMA grammar (supports ECMA-262 Standard 3rd edition). This release is meant for testing purposes only. The tool is considered "Alpha" at this point, so use at your own risk, and we won't be doing lots of support for it right now. Also, only a few tasks have been implemented so far (janitor, muffler, prettyprinter). You can get it from svn here: svn co http://svn.dojotoolkit.org/dojo/trunk/tools/jslinker There is more work to be done, but I need to call out the following efforts so far:
  • Satish Sekharan, the Google Summer of Code student, who did a great job in creating a license-compatible JS grammar file that works with ECMAScript, 3rd edition. Satish also reorganized the code to fit with the JSL name and removed some of the tasks that don't work yet with the new grammar (we plan to add them back as time allows). Excellent work Satish!
  • Uwe Hoffmann, the original author of the code. He also did some initial cleanup, and was very open and helpful. Thank you for writing such a neat tool in the first place (and thanks to the old iamaze/dig team for seeing a need for this tool and being ahead of their time).
  • Morris Johns, a SoC mentor and Dojo contributor on the project. He kept us on track and offered technical assistance on the grammar.
  • AOL for their generosity by donating the code.

One option you might want to

One option you might want to set in EcmeScript.jjt is CACHE_TOKENS. It's a boolean option; setting it to "true" can get you a few percentage points of runtime performance. And the generated parser code is actually slightly smaller!

Tom, Thank you for the tip :)

Tom, Thank you for the tip :)

[...] The Dojo Foundation

[...] The Dojo Foundation has been very lucky in having had so many supporters (Google, Mozilla, SitePen) and so many interested students and mentors for the summer internships. While some of them aren’t yet wrapped up, today’s announcement of the linker hitting trunk makes me want to at least give an overview of what’s been accomplished so far. [...]

[...] AOL has been very

[...] AOL has been very generous by donating code for the JS Linker for Dojo: The JavaScript source code can be represented in different levels of granularity. The JavaScript Linker uses the Abstract Syntax Trees (ASTs) representation, which represents the lowest level of detail, to model the source code. One of the main task for this project was to write a JavaCC compatible grammar that strictly follows the ECMA Specification. JavaCC uses this grammar to build a custom parser than can read and analyze the JavaScript source, which in turn, is used to build the JavaScript Linker. [...]

[...] JS Linker in Dojo |

[...] JS Linker in Dojo | ajaxian [...]

[...] On their blog, Dojo

[...] On their blog, Dojo posted news of the JS Linker being committed to the project’s repository: [...]

[...] It looks like the Dojo

[...] It looks like the Dojo developers have released a JavaCC Grammar for EcmaScript, more specifically ECMA-262 Standard 3rd edition. [...]

[..]couldn't resist blogging

[..]couldn't resist blogging this... it's an awesome tool![..]

[..]It's a pretty hefty

[..]It's a pretty hefty grammar with a bunch of productions, and it looks like they did a nice job using the JJTree node descriptors[..]

FYI, if not already obvious,

FYI, if not already obvious, is that a major goal is that this could be used without Dojo, if so desired.