Performant DOJO

Avatar von marketing

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
XHTML Attributes do not need to be noted down in the markup, they can be added programmatically. In any HTML / JS contect you can choose to add them by js code, may it be dojos event connect or the pure javascript methods that add event functionality to the dom.
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.

5. Dont use javascript global scope in your 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.

Avatar von marketing

Kommentare

Eine Antwort zu „Performant DOJO“

  1. I like the blog very much currently, I am working on simple dojo examples and I found the toolkit very powerful.
    These performance tips has helped me a lot.
    I referred the performance tips on my new IT DEDICATED blog http://4developer.blogspot.com

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert


Für das Handling unseres Newsletters nutzen wir den Dienst HubSpot. Mehr Informationen, insbesondere auch zu Deinem Widerrufsrecht, kannst Du jederzeit unserer Datenschutzerklärung entnehmen.