[dojo-contributors] self executing scripts

Peter E Higgins dante at dojotoolkit.org
Sun May 31 15:43:40 EDT 2009


James Burke wrote:
> On Sun, May 31, 2009 at 8:00 AM, Peter E Higgins <dante at dojotoolkit.org> wrote:
>   
>> <script src="dojo/dojo.js" djConig="parseOnLoad:true">
>>    dojo.require("dijit.TitlePane");
>>    dojo.require("dijit.layout.BorderContainer");
>>    // or just:
>>    dojo.require("my.application");
>> </script>
>>     
>
> I am not sure it is needed. We support require and addOnLoad handling
> via djConfig already, and this patch only works for the dojo.js script
> tag -- the user cannot generically apply this technique for any script
> tag. I would think the progressive JS case would prefer not to have
> any JS call in the HTML, just the script tag to load external scripts.
> For requires, the djConfig syntax is shorter to type.
>
>   
yes, but addOnLoad/requires doesn't allow you to actually _do_ much in
light cases:

<script src="dojo/dojo.js">
      dojo.require("dojo.fx.easing");
    (function(d){
     var handler = function(e){
          // lots of fun prototyping code
     } 

      var Thinger = function(args){
          d.mixin(this, args);
      }

       d.addOnLoad(function(){
             d.query(".thinger").onclick(handler).instantiate(Thinger);
               setTimeout(function(){
                      d.require("some.appstuff");
                      /* stuff way later. */
               }, 10000);
       });
     })(dojo);
</script>

> Maybe it can just be a dojox module, and we modify base just to hold
> on to the script tag, if folks feel like this is really useful.
>
>   
No, much like plugd, the ease of _using_ these types of things is
important. Saying you have to:

<script djConfig="require:[dojox.self]" src="dojo/dojo.js">
    dojo.require("more.stuff");
    dojo.addOnLoad(function(){

    });
</script>

makes it more complicated than it is worth, thus eliminating the
usefulness. :)

Regards,
Peter

> James
> _______________________________________________
> dojo-contributors mailing list
> dojo-contributors at mail.dojotoolkit.org
> http://mail.dojotoolkit.org/mailman/listinfo/dojo-contributors
>
>   


-- 
Peter E Higgins
Dojo Project Lead : http://dojotoolkit.org 



More information about the dojo-contributors mailing list