So you've built an application using Dojo and it "feels slow". Now what? Unfortunately, you can't send the latest Dual Core processors to your users But fortunately, experience has taught us that in JavaScript, smaller = faster, no matter what the client. So basically, you want to concentrate on the size of your pages. The smaller they are, the less time it takes to download, parse and execute them.
By default, all dojo.require() statements try to find the module in memory first. If it's not present, it will ask the server for a "full sized" version of the code in a synchronous manner , and incurring network I/O overhead. Synchronous network requests from a browser are necessary for loading external code because it's the only way to block execution of JavaScript while dependencies are satisfied. Once the code is fecthed it is then eval()'d and execution picks up after the dojo.require() statement.
Unfortunately synchronous IO requests also have the effect of "locking" the UI of the browser, preventing loading other resources affecting the layout of the page. Each request is serial. The package system doesn't know enough to try to request multiple files at once. To be fair, scripts included in a page via the <script> tag also suffer from the same serial behavior.
But there are still plenty of things you can do:
Use Dojo's custom build system. A custom build of Dojo will improve the download of the page by grouping related modules into one script, and optimizing it for fast parsing. See The Package System and Custom Builds for more information.
It sounds obvious, but many web pages have a lot of unnecessary markup. For example, instead of /* GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) */ .geshifilter {font-family: monospace;} .geshifilter .imp {font-weight: bold; color: red;} .geshifilter .kw1 {color: #b1b100;} .geshifilter .kw2 {color: #000000; font-weight: bold;} .geshifilter .kw3 {color: #000066;} .geshifilter .coMULTI {color: #808080; font-style: italic;} .geshifilter .es0 {color: #000099; font-weight: bold;} .geshifilter .br0 {color: #66cc66;} .geshifilter .st0 {color: #ff0000;} .geshifilter .nu0 {color: #cc66cc;} .geshifilter .sc0 {color: #00bbdd;} .geshifilter .sc1 {color: #ddbb00;} .geshifilter .sc2 {color: #009900;}
just do: /* GeSHi (C) 2004 - 2007 Nigel McNie (http://qbnz.com/highlighter) */ .geshifilter {font-family: monospace;} .geshifilter .imp {font-weight: bold; color: red;} .geshifilter .kw1 {color: #b1b100;} .geshifilter .kw2 {color: #000000; font-weight: bold;} .geshifilter .kw3 {color: #000066;} .geshifilter .coMULTI {color: #808080; font-style: italic;} .geshifilter .es0 {color: #000099; font-weight: bold;} .geshifilter .br0 {color: #66cc66;} .geshifilter .st0 {color: #ff0000;} .geshifilter .nu0 {color: #cc66cc;} .geshifilter .sc0 {color: #00bbdd;} .geshifilter .sc1 {color: #ddbb00;} .geshifilter .sc2 {color: #009900;}