> Hi everyone,
>
> I'm trying to reduce the number of file requests per page load for my
> dojo enhanced ZF app. I created a profile and generated a release,
> but I still have 32 or so file requests. Some of them look like
> duplicates, as well.
>
> I'm kinda stuck between the documentation on the dojo site (started
> with the documentation for an early version, but that was a total
> waste of time). I've looked at Matthew's pastebiin demo app (both the
> download tarball, and the most recent stuff on github), and also read
> a bunch of posts here. Seems like all of this is a fast moving
> target. None of the examples match the docs or posts.
>
> Is there recent documentation on the best way to go about this?
>
The work-in-progress wiki docs are available at:
http://docs.dojocampus.org/quickstart/custom-builds
They will replace the "old book" as soon as they are completed. the
campus wiki exports to about a 650 page PDF now, but still lacks some
explanation. We're working to finalize this before 1.3 ships. Nothing
new has gone into Dojo without full documentation between 1.2 and 1.3,
and we're retroactively trying to fill in any missing blanks.
The build isn't much of a moving target -- it really seldom changes --
it just does a lot and is somewhat complicated when you want to start
doing advanced things. At some point you just "get it", and it is rather
intuitive, but difficult to explain. I'm working on extended text for
all the todocs: at the bottom of the build page.
the jist, and easiest way i've found is to assume you will be doing a
build from the start (you should, no one should use that many files
outside of dev work), and create a physical "layer" in a namespace.
(sibling folder of dojo/ or a registerModulePath'd folder).
dojo/
my/
dijit/
dojox/
util/
and my/layer.js is:
dojo.provide("my.layer");
dojo.require("my.things");
dojo.require("dijit.things");
dojo.require("dojo.dnd.Mover"); // etc etc
then your profile just says "my.layer is dependent on my.layer" -- thus
making an automatic rollup transparent between dev and production. While
you are working, layer.js is just a list of requires sending off
additional requests (no requests will be duplicated, as you mentioned,
they should all be unique, and no-op when a module is requests
previously) ... After you build, layer.js will be the culmination of all
the inline require() calls and their dependencies.
a profile for that (save in util/buildscripts/profiles/my.profile.js):
dependencies = {
stripConsole: "normal",
layers: [
{
name: "../my/layer.js",
resourceName: "my.layer"
dependencies: [
"my.layer"
]
}
],
prefixes: [
[ "my", "../my" ],
[ "dijit", "../dijit" ],
[ "dojox", "../dojox" ]
]
}
Then run a build (util/buildscripts/) You'll need js.jar (Rhino 1.7+)
and shrinksafe.jar, both come shipped with the -src archives available
on http://download.dojotoolkit.org/current-stable/
# basic build:
./build.sh action=release profile=my version=1.2.3
# shrinksafe build:
./build.sh action=release profile=my version=1.2.3 optimize=shrinksafe
# css concatenation?
./build.sh action=release profile=my version=1.2.3 optimize=shrinksafe
cssOptimize=comments.keepLines
# i like keepLines in my css as I sometimes use line-specific hacks that
would be destroyed otherwise
(profile=my assumes profiles/value.profile.js. you can do profileFile
and pass an absolute path if you like instead)
There are a lot of options to work with, and even more goodies within
the build to do very specific things (like omit a whole block of code
for production based on specially crafted comment tags, lazy-requiring
of modules, etc). run ./build.sh without options to see the CLI docs
there about supported command line params.
a folder "release/dojo/" will be made as a sibling of dojo/ ... all
dojo.require()'ing is done relative to dojo.js, so if you point your
page at the 'release' dojo.js, the rest of your modules will be from the
release tree too (layer included)
<!-- simply comment out or use some server-side goodness to determine
dev or production -->
<script src="/js/lib/dojotoolkit/dojo/dojo.js"></script>
<script src="/js/lib/dojotoolkit/release/dojo/dojo/dojo.js"></script>
<!-- this stays the same, regardless -->
<script>dojo.require("my.layer")</script>
Hope this helps. If you have more specific questions, or spot anything
wildly inaccurate in the wiki docs, please don't hesitate to let me
know. Improving Dojo's documentation availability and IA has been my #1
priority since taking this position, and we've made great strides
towards it's completion ... but review is always helpful and necessary.
Regards,
Peter Higgins
没有评论:
发表评论