[dojo-contributors] Dojo 1.7 Goals: has() and granular dependency lists

Kris Zyp kzyp at dojotoolkit.org
Mon Mar 14 13:07:39 EDT 2011


On 3/14/2011 10:45 AM, ben hockey wrote:
> the ticket claims that using has like you've done is better for
> compression but can you point to an example or explain why it
> compresses better?  i haven't been closely following the thread about
> using closure with dojo 1.6 - maybe it was somewhere in there? 

Here is the test I did. I took:

define(["has"], function(has){
    has.add("test", test);
    if(has("test")){
        alert("hi")
    }
});

and compressed it (with closure, simple mode):

define(["has"],function(a){a.add("test",test);a("test")&&alert("hi")});

And then:

define([], function(){
    var features = {
        "test": test
    };
    function has(feature){
        return features[feature];
    }
    if(has("test")){
        alert("hi")
    }
});

and compressed it:
define([],function(){({test:test}).test&&alert("hi")});

And the latter was smaller.
Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-contributors/attachments/20110314/145ca25a/attachment.htm 


More information about the dojo-contributors mailing list