Login Register

Using Package system - error loading new .js file

Hello. I've been trying to use the package system for the first time to create a compressed release version of Dojo for my site. I was able to get the script to execute properly by running it with the following command:

build.bat profile=attic action=release releaseName=dojo-root optimize=shrinksafe layerOptimize=shrinksafe

I pulled the entire release directory into my project and I'm trying to reference the new .js file, but I'm getting a javascript error on page load saying it can't recognize "dojo". Here is some additional information.

My file "attic.profile.js" has the following:

dependencies ={
layers: [
{
name: "atticdojo.js",
dependencies: [
"dojox.widget.FisheyeLite"
]
}
],
prefixes: [
[ "dijit", "../dijit" ],
[ "dojox", "../dojox" ]
]
};

As you can see, I'm only using the FisheyeLite widget so far. In my JSP page, I replaced this line (pulls inthe javascript):

script type="text/javascript" src="javascript/dojo-root/dojo/dojo.js" djConfig="parseOnLoad: true"

with this one:

script type="text/javascript" src="javascript/dojo-root/dojo/atticdojo.js" djConfig="parseOnLoad: true"

If I include only the "dojo.js" file, it works just fine. Do I need to include them both? If so, what exactly is the purpose of the newly generated file? My understanding is that this is supposed to replace "dojo.js" to limit how much gets loaded at runtime. If anyone can assist me with this, I would greatly appreciate it. Thanks!

yes, you need dojo.js

yes, you need dojo.js (always one thing) and your atticdojo.js file ... that is the recommended method.

you _can_ however mix FisheyeLite into dojo.js and produce a single .js file for inclusion, holding both base dojo + fisheye ... look at the profile layers.profile.js ... you can see an example of how to put additional files in the base. Just name your layer dojo.js

at which point you'll have probably about 112k .js, which will compress to around 37k (base included, which is 27k) ... Wow, I guessed right!

here's the profile I used:

dependencies = {
        layers: [
                {
                        name: "dojo.js",
                        dependencies: [
                                "dojox.widget.FisheyeLite"
                        ]
                }
        ],

        prefixes: [
                [ "dijit", "../dijit" ],
                [ "dojox", "../dojox" ]
        ]
};

http://dante.dojotoolkit.org/dojo-fishy.js
^^ give that a shot (direct [script src=] tag in your page) and see if that works for you, though my sandbox doesn't have gzip enabled. It is also a build directly out of svn trunk, so you may want to use 1.1 exclusively, and I can't guarentee that file will always exist there ... but it should be standalone (until you try to dojo.require something else ;) )

oh and to clarify, dojo.js

oh and to clarify, dojo.js is "always the same thing". the purpose of the atticdojo.js "layer" is to compress and concat any requirements the module has into a single file. In this case, dijit.dijit, and dijit._Widget (10k) and FisheyeLite.js (3k or so). The savings get better the "more you use", though in this case the savings aren't as apparent (mostly just the number of requests overall have been cut)

Thank you. One more clarifying question.

Hello. Thank you for the good information! So, if I'm understanding this correctly, if the second javascript include is not there (the compressed file), does this mean that dojo.js will start digging into individual files, affecting performance? Also, are there any performance benefits to having 2 files or just putting everything into dojo.js as you detailed above? Sounds like it might just be a developer preference, but I wanted to check to make sure. Thanks!

it really is a developer

it really is a developer preference. We, as Dojo, say "dojo.js is always the same, so don't add stuff to it, add your layer.js on top of it" ... That way, you are able to reuse a single cached dojo.js regardless of which page / effect / widget you want.