Improve dojo performance in Zend Framework

7 Jan

After using dojo calendar in my application, I feel that it take lot of time loading dojo js files. This not only bothered me but also the client I am working with. However yesterday when listen a webinar  of Methew -Zend framework architect and responsible for framework and dojo integration, I come to conclusion that the requests can be limited to one or two by using custom builds.

As I was new and was unable to understand it from the webinar, I visited dojo toolkit website and read article about custom builds there. Although that article can help you however they don’t have given how to use it with the Zend Framework.

So in this post I am going to discuss how you can improve performance of dojo by limiting the number of request.

So let’s get started.

First go to “dojo/util/buildscripts/profiles” and create foo.profile.js and write the following code in it.

dependencies={

 

 

layers: [

{

name: “custom.js”,

dependencies: [

‘dijit.form.Form’,

‘dijit.form.Button’,

‘dijit.form.DateTextBox’,

‘dijit.form.Checkbox’

]

},

],

prefixes:[

[‘dijit’,’../dijit’],

[‘dojox’,’../dojox’],

]

}

Save this file and open command prompt in window/linux

Now in script go to the util/buildscripts using command as

C:\> cd xampp/htdocs/Zend/js/dojo/util/buildscripts/

Keep in mind that you may have different directory structure. So you will need to change this path. Now write

C:\ xampp/htdocs/Zend/js/dojo/util/buildscripts>  build.bat profile=foo action=release

After executing

build.bat profile=foo action=release

You will find a new directory “release” created in you dojo directory. This is the compact version of the dojot toolkit.

Note: use build.sh instead of build.bat in the command if you are using linux.

Now this is the directory for your production. Copy this directory to your application and set your apths in the layout file as

$this->dojo()->setDjConfigOption(‘usePlainJson’,true)

->addStylesheetModule(‘dijit.themes.tundra’)

->setLocalPath(“/js/dojo/release/dojo/dojo/dojo.js”)

->addLayer(“/js/dojo/release/dojo/dojo/custom.js”);

echo $this->dojo();

Not that we have only setLocalPath and addLayer(). addLayer() contain path to the cutom file you create in the foo.profil.js. this file will be generate for you and will be placed in the realease/dojo/dojo/ directory.

One Response to “Improve dojo performance in Zend Framework”

  1. Umer January 28, 2010 at 3:29 pm #

    Hi all, my problem is as follows:

    Actually i make two sub forms in two different form files then make their objects like
    1) infor_form and 2) reg_form and add them using addSubForm. All working fine but title of 2 tab is not displaying. Kindly tell me the solution if anybody have.

    Thanks

    $info_form = new AML_Form_ClientInfoForm();
    $reg_form = new AML_Form_ClientRegForm();
    $this->addSubForm($info_form, ‘textboxtab’)->addSubForm($reg_form, ‘editortab’);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: