I created a branch http://bugs.dojotoolkit.org/browser/branches/jsdoc
to test JSDoc style comments in our source code, rather than our
proprietary format.

Running it through the JSDoc Toolkit parser yields results in:
http://bill.dojotoolkit.org/jsdoc/

The conversion seems doable, which isn't surprising given that all the
other toolkits are already using this format. There are some gotchas
with jsdoc-toolkit though:
- class names with an underscore don't work, needed to rename _Widget to
Widget, etc.
- missing keywords: protected, readonly, callback, extension

------------
I then moved on to google closure compiler. Closure compiler has it's
own requirements; for example, the type specification needs to match
http://code.google.com/closure/compiler/docs/js-for-compiler.html#types.

After updating _Widget.js to make the closure compiler happy, I'm able
to use closure compiler in both simple and advanced mode:
36769 original _Widget.js
9403 shrinksafed _Widget.js
8184 closure compiler simple mode
5597 closure compiler advanced mode

That's a pretty impressive compression improvement, although I think to
really test it we would need to convert all of our code to JSDoc format,
including all the dojo core modules, not just the few dijit files I
converted. Still, worth more investigation.

In _Templated.js I'm getting lots of warnings about the use of "this",
etc. Seems closure doesn't understand @lends and therefore isn't
understanding dojo.declare(). I'm not sure what to do about that. Maybe
just adding @this metadata for every method, but I'm uneasy about
closure not understanding our classes. Looks like google doesn't use
anything like dojo.declare, see for example
http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/fx/abstractdragdrop.js
towards the bottom, or
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml).

Search Discussions

  • Eugene Lazutkin at Sep 20, 2010 at 1:05 pm
    The results are pretty impressive --- 40% gain compared to the
    shrinksafed version. I hope you ran the code to make sure that it
    actually worked. ;-)

    Regarding understanding of dojo.declare and some other Dojo constructs.
    I have a feeling that I've read somewhere in Google Closure docs that in
    the advanced mode it uses a special knowledge of certain Google Closure
    functions. I don't know if:

    1) It is still the case.

    2) It is possible to add your stuff to this "special knowledge".

    3) How easy it is to add your stuff, e.g., one-line addition to some
    table, or rewriting the whole compiler.

    It would be nice if somebody looked into that, or shared his/her
    existing knowledge on this topic.

    Cheers,

    Eugene Lazutkin
    http://lazutkin.com/


    On 09/20/2010 10:03 AM, Bill Keese wrote:
    I created a branch http://bugs.dojotoolkit.org/browser/branches/jsdoc
    to test JSDoc style comments in our source code, rather than our
    proprietary format.

    Running it through the JSDoc Toolkit parser yields results in:
    http://bill.dojotoolkit.org/jsdoc/

    The conversion seems doable, which isn't surprising given that all the
    other toolkits are already using this format. There are some gotchas
    with jsdoc-toolkit though:
    - class names with an underscore don't work, needed to rename _Widget to
    Widget, etc.
    - missing keywords: protected, readonly, callback, extension

    ------------
    I then moved on to google closure compiler. Closure compiler has it's
    own requirements; for example, the type specification needs to match
    http://code.google.com/closure/compiler/docs/js-for-compiler.html#types.

    After updating _Widget.js to make the closure compiler happy, I'm able
    to use closure compiler in both simple and advanced mode:
    36769 original _Widget.js
    9403 shrinksafed _Widget.js
    8184 closure compiler simple mode
    5597 closure compiler advanced mode

    That's a pretty impressive compression improvement, although I think to
    really test it we would need to convert all of our code to JSDoc format,
    including all the dojo core modules, not just the few dijit files I
    converted. Still, worth more investigation.

    In _Templated.js I'm getting lots of warnings about the use of "this",
    etc. Seems closure doesn't understand @lends and therefore isn't
    understanding dojo.declare(). I'm not sure what to do about that. Maybe
    just adding @this metadata for every method, but I'm uneasy about
    closure not understanding our classes. Looks like google doesn't use
    anything like dojo.declare, see for example
    http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/fx/abstractdragdrop.js
    towards the bottom, or
    http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml).
  • Bill Keese at Sep 21, 2010 at 12:36 am
    I posted to
    https://groups.google.com/group/closure-compiler-discuss/browse_thread/thread/6097fb34132245e2,
    hopefully someone will answer.

    For the record, I didn't test the compressed output. I tried to say in
    my original note that it *won't work* unless all of dojo is compressed
    at the same time. I guess that's not actually true, that I can get it
    to work by using the compiler externs/exports feature, but I didn't try
    that.

    I think the interesting number is when the whole app (including all of
    dojo) is compressed, so that all the global symbols (like dijit._Widget
    and dojo.marginBox) can be compressed too. It's obviously tricky
    though, as we will need to mark exceptions for things like widgets
    referenced via dojoType=...
    On 9/21/10 2:05 AM, Eugene Lazutkin wrote:
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    The results are pretty impressive --- 40% gain compared to the
    shrinksafed version. I hope you ran the code to make sure that it
    actually worked. ;-)

    Regarding understanding of dojo.declare and some other Dojo constructs.
    I have a feeling that I've read somewhere in Google Closure docs that in
    the advanced mode it uses a special knowledge of certain Google Closure
    functions. I don't know if:

    1) It is still the case.

    2) It is possible to add your stuff to this "special knowledge".

    3) How easy it is to add your stuff, e.g., one-line addition to some
    table, or rewriting the whole compiler.

    It would be nice if somebody looked into that, or shared his/her
    existing knowledge on this topic.

    Cheers,

    Eugene Lazutkin
    http://lazutkin.com/


    On 09/20/2010 10:03 AM, Bill Keese wrote:
    I created a branch http://bugs.dojotoolkit.org/browser/branches/jsdoc
    to test JSDoc style comments in our source code, rather than our
    proprietary format.

    Running it through the JSDoc Toolkit parser yields results in:
    http://bill.dojotoolkit.org/jsdoc/

    The conversion seems doable, which isn't surprising given that all the
    other toolkits are already using this format. There are some gotchas
    with jsdoc-toolkit though:
    - class names with an underscore don't work, needed to rename _Widget to
    Widget, etc.
    - missing keywords: protected, readonly, callback, extension

    ------------
    I then moved on to google closure compiler. Closure compiler has it's
    own requirements; for example, the type specification needs to match
    http://code.google.com/closure/compiler/docs/js-for-compiler.html#types.

    After updating _Widget.js to make the closure compiler happy, I'm able
    to use closure compiler in both simple and advanced mode:
    36769 original _Widget.js
    9403 shrinksafed _Widget.js
    8184 closure compiler simple mode
    5597 closure compiler advanced mode

    That's a pretty impressive compression improvement, although I think to
    really test it we would need to convert all of our code to JSDoc format,
    including all the dojo core modules, not just the few dijit files I
    converted. Still, worth more investigation.

    In _Templated.js I'm getting lots of warnings about the use of "this",
    etc. Seems closure doesn't understand @lends and therefore isn't
    understanding dojo.declare(). I'm not sure what to do about that. Maybe
    just adding @this metadata for every method, but I'm uneasy about
    closure not understanding our classes. Looks like google doesn't use
    anything like dojo.declare, see for example
    http://code.google.com/p/closure-library/source/browse/trunk/closure/goog/fx/abstractdragdrop.js
    towards the bottom, or
    http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml).
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.10 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

    iEYEARECAAYFAkyXlFgACgkQY214tZwSfCupXACaAkcoNIprf94VjusH9aEu0cXQ
    FKcAniLVnp4Io8SxoPjEYGKoPtTBpRjm
    =QY14
    -----END PGP SIGNATURE-----
    _______________________________________________
    dojo-contributors mailing list
    dojo-contributors at mail.dojotoolkit.org
    http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
  • Bill Keese at Sep 23, 2010 at 4:51 am
    About support for kwArgs type arguments, like dojo.xhr() takes:

    JSDoc Toolkit
    ------------
    As pointed out in the meeting, simple kwArgs arguments can be specified
    as anonymous types like in the bottom of
    http://code.google.com/p/jsdoc-toolkit/wiki/TagParam:

    /**
    * @param userInfo Information about the user.
    * @param userInfo.name The name of the user.
    * @param userInfo.email The email of the user.
    */
    function logIn(userInfo) {
    doLogIn(userInfo.name, userInfo.email);
    }




    When you want to actually define a new type (with a name) like
    dojo.__xhrArgs, it can be declared fully in comments:

    /**
    * This is the argument list passed to dojo.xhr() etc.
    * @name dojo.__xhrArgs
    * @class
    * @property {String} url The URL
    * @property {Number} timeout The timeout
    */


    Closure compiler
    --------------
    Closure compiler is a different, see bottom of
    http://code.google.com/closure/compiler/docs/js-for-compiler.html, you
    specify anonymous types like:
    {{url: String, timeout: Number}}|
    To declare a new named type you would do:

    /** @typedef |{{url: String, timeout: Number}}| */
    dojo.__xhrArgs;

    Closure will presumably strip that "dojo.__xhrArgs" from the code. If
    not, another way to protect against code bloat would be to put such
    "typedefs" in another file, like we did with
    http://bugs.dojotoolkit.org/browser/dojo/trunk/data/api (that example
    is actually an @interface, not a @typedef)

    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20100923/ef5076f5/attachment.htm

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdojo-contributors @
categoriesdojo
postedSep 20, '10 at 11:03a
activeSep 23, '10 at 4:51a
posts4
users2
websitedojotoolkit.org

2 users in discussion

Bill Keese: 3 posts Eugene Lazutkin: 1 post

People

Translate

site design / logo © 2022 Grokbase