[dojo-contributors] Prototype-al simplicity

Aaron Boodman zboogs at gmail.com
Mon Apr 10 22:40:17 EDT 2006

Just as an outside observer, I'd like to point out that the title of
this post includes the word "simplicity", not "size".

I don't think dojo'ers time is best spent trying to figure out clever
ways to shave bytes. I do think the goal of making dojo simpler to use
is a fine one. But that is orthogonal to download size.

These types of problems are best left to a compiler anyway. Write in a
style that makes sense, then let the compiler shorten all of:

dojo.monkey.Foo.prototype.blah = function() { ... }


var f25 = dojo.monkey.Foo.prototype;
f25.blah = function() { ... }

There are tons of other optimizations like this that only a compiler
can really do.

- a

On 4/10/06, Brian Douglas Skinner <skinner at dojotoolkit.org> wrote:
> Bill Keese wrote:
> >>One small thing is to declare all the functions like they are part
> >>of an object (or part of a package?), like this:
> >>
> >>dojo.style = {
> >>        getPixelValue: function() { ... },
> >>        getNumericStyle: function() { ... },
> >>};
> James Burke wrote:
> > I personally like that style. It does save some space, but it is
> > a little more error-prone (be sure to test in MSIE to make sure
> > you don't leave a trailing comma after the last property definition).
> That trailing comma problem is one of the things that Douglas
> Crockford's JSLint utility checks for.  On the OpenRecord project, we've
> set up our unit tests to run JSLint on all the code, and we try not to
> ever check in code that doesn't pass the unit tests.  That may seem
> compulsive, but it does defend against some types of bugs that you
> otherwise wouldn't find out about until after you ship.  As Dojo gets
> closer to 1.0 it might be useful to automate more testing.
> :o) Brian
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-contributors

More information about the dojo-contributors mailing list