Wednesday, May 29, 2013

dojoConfig versus data-dojo-config within... Dojo!

This offers: "Notice that dojoConfig is defined in a script block before dojo.js is loaded. This is of paramount importance—if reversed, the configuration properties will be ignored." ...while giving this code as an example:

<script>
   dojoConfig= {
      has: {
         "dojo-firebug": true
      },
      parseOnLoad: false,
      foo: "bar",
      async: true
   };
</script>
<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"></script>

 
 

Okey-dokey, this example is also given by the same source as a way to jam the dojoConfig JSON into a script tag as an HTML5 Custom Data Attribute:

<script src="//ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js"
   data-dojo-config="has:{'dojo-firebug': true}, parseOnLoad: false, foo: 'bar', async: 1">
</script>

 
 

Note:

  • async: true ...denotes if Dojo itself should be loaded asynchronously, allowing, if true, for the app to come to life before everything is sucked down to the client.
  • When using dojox:
    • The app I am looking at currently has a separate script tag for calling /dojox/mobile/deviceTheme.js and thus this app is using the data-dojo-config convention to pass the the configurations so that it may delinate configurations between the two script tags. (I'm guessing.)
    • There is also going to be an independent config.json file for dojox (perhaps) but I don't understand it yet. config.json is not managing the same thing that dojoConfig/data-dojo-config is. (I'm pretty sure.)

No comments:

Post a Comment