1

Is Dojo's load-as-you-need it structure actually a performance improvement? For me, at least?

My company's website is going to switch to IBM Websphere, which primarily uses Dojo. My company's very concerned with page performance, mostly in terms of "seconds to page load". As a result of that, the directive we've been given is "minimize hits to the server", so with our current website we aggregate all our .js files before the promotion to production.

But that directive is basically becoming Law, now, so if I were to argue against it, I would need a very good rationale for it. I've been unable to find anything in favor of the load-as-you-go method except "it's a good idea" and "loads only when you need it" (the latter is really only based on the former, as far as I can tell).

And then, if I were to flatten everything out into a single file, I wouldn't be able to use dojo.require() statements at all, would I? (the idea being, if I could have the development side split by module to make the organization more rational, but then have the production version a single file, but then dojo.require() would no longer make sense there, and then I have an increasingly complex situation where I would need the build to do some invasive things to the javascript to package for production.)

Please resist the "it depends" answer. The best practices docs I've seen (Yahoo, Google, etc) pretty much just say "reduce page loads" and don't have much "it depends" about it. But Dojo's framework seems so definitive about its approach, I'm wondering if there's a more persuasive argument for it.

1 Answer 1

1

Dojo actually combines the two approaches. In development mode, you have many files that use define (dojo.require is obsolete) to load other modules dynamically. This is very good for abstraction and development.

Then there is "production mode", where you compile all those small files into one or more (aka. layers) minified Javascript files with the dojo build system. This reduces hits to the server while still maintaining all the modularity. With the layer approach, application data that is needed later will automatically be loaded from a separate file.

See: http://dojotoolkit.org/blog/learn-more-about-amd

http://dojotoolkit.org/reference-guide/1.7/build/

1
  • Hm, yeah, we're using Dojo 1.5 (yeah I know, new website, my company enjoys its planned obsolescence), but I see that page has a link to the build process for pre-1.7. Okay, I'll have to start looking into that, thanks.
    – spinn
    Commented Aug 1, 2012 at 17:48

Not the answer you're looking for? Browse other questions tagged or ask your own question.