-- Ralf Eggert <[email protected]> wrote
(on Wednesday, 22 September 2010, 06:02 PM +0200):
> thanks for your reply. Unfortunately, I need to ask some further
> questions for clarification.
>
> > IIRC, the way I "fixed" the behavior was through some odd permutations
> > of dojo.addOnLoad (now dojo.ready in 1.5). However, the ultimate fix is
> > one that you should be doing anyways: create a custom build.
>
> The problem is, I am already using a custom build. At least I think I
> was. I created it with these two commands:
>
> cd /home/zf/ZendFramework-1.10.8/externals/dojo/util/buildscripts
>
> ./build.sh profileFile=profiles/standard.profile.js
> action=clean,release version=1.4.1 releaseName=
>
> Then I copied all the files from the /dojo/release path to my web
> project. Then in my layout script I simply do this:
>
> if ($this->dojo()->isEnabled())
> {
> $this->dojo()->setLocalPath('/js/dojo/dojo.js');
> $this->headLink()->prependStylesheet(
> '/js/dijit/themes/tundra/tundra.css', 'screen, print');
> echo $this->dojo();
> }
>
> I thought this is the right way to setup a custom build, isn't it?
I should clarify: you want a build _layer_. This requires creating a
build profile that details the various dependencies your application
will use. When you create a build in this way, all the dependencies are
then slurped into a single file.
The Dojo documentation for creating layer profiles is here:
http://docs.dojocampus.org/build/index
and ZF has support for helping you create the build profiles in
Zend_Dojo_BuildLayer:
http://framework.zend.com/manual/en/zend.dojo.build-layers.html
Give that a try, and see if it helps things out.
IIRC, Dojo 1.5 or 1.6 offers some functionality around automating this,
but you'll need to read through the changelogs to verify.
> > By creating a custom build, you basically eliminate the synchronous XHR
> > calls (yes, synchronous) used by Dojo to load modules. It also ends up
> > looking a lot like one of the solutions you found:
> >
> > <!-- dojo.js always provides the package system and base utilities -->
> > <script type="text/javascript" src="/js/src/dojo/dojo.js"></script>
> >
> > <!-- include the rest of the modules we need -->
> > <script type="text/javascript" src="/js/src/acme/mylayer.js"></script>
> >
> > Custom builds are also magnitudes faster than pulling in the modules via
> > XHR -- not only do you eliminate the network latency, but the build
> > system also optimizes the code.
>
> Since I thought, I am already using a custom build, I wondered today
> when I looked at the request within Firebugs network module. On one page
> there are 119 requests. 35 of them are XHR and another 38 of them are
> Dojo related CSS requests. So somethings must be wrong with my custom
> build since I still have a lot of single Dojo related requests.
>
> Could that be the problem?
>
> > In the meantime, instead of echoing out $this->dojo(), build a
> > dojo.addOnLoad() callback that first loads the required modules, and
> > then queues another dojo.addOnLoad() event to trigger any other setup:
> >
> > dojo.addOnLoad(function() {
> > dojo.require(...);
> > dojo.require(...);
> > dojo.addOnLoad() {
> > // do some other stuff...
> > }
> > });
> >
> > This approach helps to ensure all the modules are loaded before any
> > other code executes -- though it will not fix issues where FF does not
> > find the scripts in the first place.
>
> But when I echo out $this->dojo() first all dojo.require() are printed,
> followed by the dojo.addOnLoad() function to loop through the
> zendDijits, followed by the dojo.parser.parse(), followed by other
> dojo.addOnLoad() functions to set up forms for validation and finally
> followed by the zendDijits declaration.
>
> I thought this already ensures that all modules are loaded before any
> code execution?
>
> > To be honest, I haven't tried using 1.5 yet, much less with ZF. That
> > said, when we've upgraded between versions, there have been very, very
> > few breakages, if any. Give it a try -- simply set the dojo version in
> > the view helper, and see what happens.
>
> I will give it a try. Do I understand it correctly that setting the dojo
> version in the view helper is only really needed if I use the CDN?
>
> > This is planned, and I hope to tackle it in the next couple of weeks.
> > The 1.11.0 release is planned at this point for the end of October.
>
> If the end of October is met that would be just in time ;-)
>
> Thanks and best regards,
>
> Ralf
>
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc