Is the $resources$ directory WEB-INF? On Oct 6, 2007 8:51 AM, Jeromy Evans <[EMAIL PROTECTED]> wrote: > I thought I'd share the instructions I prepared for creating a dojo > 0.4.2 custom profile for Struts 2.0.9. The objective is to bundle all > the required dojo resources into dojo.js to avoid the numerous slow > sequential requests for resources. This makes a massive performance > improvement to the default ajax theme. > > Instructions for improving the performance of dojo 0.4.2 in Struts 2.0.9: > > $resources$ is assumed to be your web resources directory > > 1. First, configure struts to serve the static files directly from > $resources$/struts instead of from within struts-core-2.0.9.jar: > > a. extract struts2-core-2.0.9.jar/org/apache/struts2/static/* to > $resources$/struts/ > b. edit struts.properties and set struts.serve.static=false > c. also extract the javascript and css files from > struts2-core-2.0.9.jar/templates/* to $resources$/struts/ as this will > be helpful later > eg. $resources$/struts/ajax/dojoRequire.js > > Confirm that your application still works before proceeding. It's > essential that resources are loaded from the directory rather than the jar. > > 2. Download the source of dojo 0.4.2. You won't need to modify it. The > download location doesn't matter. We assume it's in release-0.4.2/ > > > svn export http://svn.dojotoolkit.org/dojo/tags/release-0.4.2 > > This is almost identical to the version bundled with struts2.0.9. > > 3. Use an editor to create a dojo custom profile as the file > release-0.4.2/buildscripts/profiles/struts2.profile.js. This file > defines which dojo resources you use directly. Essentially it specifies > which code will be included in dojo.js. An example that includes almost > everything is provided at the end of this email. > > 4. Copy the struts widgets into the dojo directory so they can be > included within dojo.js. That is, copy $resources$/struts/dojo/struts/* > to release-0.4.2/struts. > This is the directory that contains the widget and widgets > subdirectories, css and some images. > > 5. Build dojo using ant. This will create a new dojo.js file: > > > cd release-0.4.2/buildscripts > > ant -Dprofile=struts2 -Dstrip_and_compress=true clean release > intern-strings strip-resource-comments > > (You may be asked to run it twice). > > Pay some attention to the build process. In particular, note whether it > finds the struts widgets and 'internalises' the related resources. If > not, see Step 4. You'll probably notice a lot of things are included > that you don't need. That will be helpful later for optimizations. > Some errors will occur while stripping the comments but these are ok. > > 6. When the build process completes the release directory will contain > all the files you need. The content of the release directory can be > copied over the top of $resources$/struts/dojo. You'll notice it's > almost exactly the same as the original, although dojo.js is probably > larger. > > It's okay to delete the demo, test and release subfolders before copying > to your application. The src subfolder must be distributed with your > application as it contains images used by dojo. > > 7. Clear your browser cache and test your application again. You should > note the larger dojo.js file being loaded and significantly fewer > requests for resources by dojo Hopefully it's also a lot faster. > > That's it. Now you can go back and optimize the profile by removing > resources you don't need. There's examples in the profiles directory. > Repeat the build/test process to find the right balance. > I also recommend editing $resources$/struts/ajax/dojoRequire.js to > remove the reference to the Editor2 if you don't use this as it's a > very,very heavy-weight resource. > > Hope that helps someone else. Improvements & comments welcome. See > reference [3] below for detailed instructions and rationale. > > regards, > Jeromy Evans > > Resources > [1] http://struts.apache.org/2.x/docs/performance-tuning.html > [2] > http://www.nabble.com/-s2--Struts-head-tag-KILLS-%28%3E-10s%29-page-load-time-tf4490390.html#a13047981 > [3] > http://www.dojotoolkit.org/book/dojo-book-0-4/part-6-customizing-dojo-builds-better-performance > > The following profile includes almost everything in dojo.js. It assumes > the struts widgets have been copied into the directory as mentioned at > step 4. > struts2.profile.js: > > var dependencies = [ > "dojo.lang.*", > "dojo.html.*", > "dojo.debug", > "dojo.html.display", > "dojo.html.layout", > "dojo.html.util", > "dojo.lfx.*", > "dojo.event.*", > "dojo.logging.*", > "dojo.io.*", > "dojo.io.IframeIO", > "dojo.date", > "dojo.string.*", > "dojo.regex", > "dojo.rpc.*", > "dojo.xml.*", > // "dojo.flash.*", > // "dojo.storage.*", > "dojo.undo.*", > "dojo.crypto.*", > //"dojo.collections.*", > "dojo.collections.ArrayList", > "dojo.collections.Collections", > "dojo.collections.Queue", > "dojo.collections.Stack", > "dojo.dnd.*", > "dojo.widget.*", > "dojo.widget.TabContainer", > "dojo.widget.PageContainer", > "dojo.widget.LinkPane", > //"dojo.widget.Editor2", > //"dojo.widget.RichText", > //"dojo.widget.Editor2Toolbar", > //"dojo.widget.ColorPalette", > "dojo.math.*", > //"dojo.reflect.*", > "dojo.uri.*", > "struts.widget.Bind", > "struts.widget.Bind", > "struts.widget.BindDiv", > "struts.widget.BindAnchor", > "struts.widget.ComboBox", > "struts.widget.StrutsTimePicker", > "struts.widget.StrutsTimePicker" > ]; > > dependencies.prefixes = [ > ["struts", "struts"] > ]; > > load("getDependencyList.js"); > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]