When your rich internet applications become more complex and mature, you learn that there are some rules to obey to achieve a sucessful dojo project. What does successful mean ?
- easy extendible
- good client performance
- easy maintainable, readable code
- economical memory usage
Our rules ;)
1. Build dojo from SVN
Its seems to be disturbing to your own work that the dojo team has comitted a fix last night that breaks a api. But, these fixes don’t come from nothing, means the chance is there that you had a warning like "xy is deprecated and will be replaced by zz" when you read the console output. You read the console messages, don’t you?
All in all its much faster on the major dojo release dates to have it all there, instead of fixing it all on one day. It is much likely that this will cost You a remarkable amount of time.
2. Use dojos compression
The compression & buildsystem is a important thing that will help you to reduce the time the whole dojo system requires to load and initially execute. A important factor if you are not using a one page Ajax application model or limited ressources.
3. good XHTML matters
Dojo parses a lot of information to get all that markup transformed into CSS styled widgets that have all that magic functionality inside. So far it is important to produce correct markup, without ANY style attributes (use class and css by id), tables only where they are required and the minimum set of (X)HTML nodes.
Examples that use only 60 Nodes (XHTML) with div/span based layout perform better than the same code with table based HTML 4.01, style attribute using markup and 185 Nodes. Simply because you tell the same story with less characters.
4. (X)HTML event attributes -> NO NO NO
Its much more likely to find all the connected and used events when you are doing that by code in ONE place and not ditributed over the whole project.
When you develop the application code using dojo and maybe a bit of DOM, avoid using variables outside your function scope. Why ?
- The variables outside the function scope are slower to access
- references to dom nodes are much likely not to get garbage collected and you will need more RAM to execute your application code over time.
You can use objects to create your application code and informations like the actual used browser (i know its implemented in dojo .. just say for fast accesses sake) can be stored in a objects member variable instead of beeing globalized around. If you are generating these objects using prototype of objects you will save some more memory on you application.
So far, these are the basics i have learned to make my life in the dojo easy and effective.
Besides you are much likely to be at home in time at the evening and able to meet timelines because refactoring and changes to dojo are not that big things and cost not too much time. Hope that helps in any way.