[Mapbender-dev] Packer (code conventions)

Christoph Baudson (WhereGroup) christoph.baudson at wheregroup.com
Fri Feb 9 07:41:19 EST 2007


Hi Marc, hi list,

thanks for your demo script. You were right, the packing algorithm 
preserves the original names. This is good news.

But still, the need for the additional semicolon has been discussed 
controversely. I think we better postpone a decision and evaluate the 
packers first.

Thanks a lot for sharing,

Christoph

Marc Jansen schrieb:
> Hey Mapbender developers,
> 
> 
> Christoph Baudson (WhereGroup) schrieb:
>> Hi Marc, hi Paul, hi list,
>>
>> Paul, JSLint is yet another great tool, thanks for sharing.
>>
>> Marc, here's what I think about your reply.
>>
>>> Yes the names are shortened, but that should not be a problem since 
>>> everything  done by Dean Edwards packer is being reverted as the 
>>> script is loaded. The whole resultung function (p, a, c, k, e, 
>>> d){...} is being evaluated at once. Different scripts are sent 
>>> through eval in the order of presence of script-tags in the markup. I 
>>> used is together with about 6 other scripts and there were no problems.
>>
>> This is quite interesting. I believed that variable names were just 
>> shortened. Where did you get your information from? 
> 
> ... I did it the inductive way: try and see: ;-)
> 
> an example script:
> 
> var aVeryLongNameThatWontBeShortened = {
>  "first" : 1,
>  "second" : 3,
>  "aMethodYeah" : function() { alert(this.first); },
>  "anotherOne" : function() { alert(typeof this.aMethodYeah); },
>  "multi" : {
>    "multiOne" : {
>      "myArray" [1, 2 , 3 , 4 , 5 , 6 ],
>      "anotherArray" ["a", "b", "c"]
>    }
>    "multiTwo" : {
>      "myArray2" [1, 2 , 3 , 4 , 5 , 6 ],
>      "anotherArray2" ["a", "b", "c"]
>    }
>  }
> };
> 
> Bhen you run this  through the compression script (getting a bigger 
> result as the scripts to small), you will get something like this 
> [shortened and with linebreaks]:
> 
> eval(
>  function(p,a,c,k,e,d){e=function(c){return c.toString(36)};  [...] 
> 'first|||||||aMethodYeah|alert|function||||this|anotherArray|multiTwo|myArray2|anotherOne|typeof|anotherArray2|aVeryLongNameThatWontBeShortened|myArray|multi|multiOne|var|second'.split('|'),0,{})) 
> 
> 
> do you see the parts at the end? These are just exactly the names I 
> chose for my stupid example. Within the function(p,a,c,k,e,d) {} the 
> methods, vars ... are referenced by their short names, but in the end 
> (after eval has done the job) your can us just what you originally typed 
> in.
> 
> But with all inductive research... one can never be sure based on 
> n-examples... so perhaps take a look at the source?
> 
> 
>> The documentation of Dean Edwards' packer is not the best.
> 
> Yes, that's right
>>
>>> Sure enough other packers should be considered. Can't we make up a 
>>> small test page in the wiki with results for some of the tools and 
>>> pros and cons for each?
>>
>> A first draft is up at
>>
>> http://www.mapbender.org/index.php/For_developers#Packing_JavaScript_code
> 
> Good start!
> 
> I think Pauls email has summed up everything nicely. And just to 
> clearify: JSMIn would be a perfect choice as well.
>>
>> Any input will be highly appreciated.
>>
> 
> Just my two cents.
> 
> -- Marc
> _______________________________________________
> Mapbender_dev mailing list
> Mapbender_dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapbender_dev



More information about the Mapbender_dev mailing list