my mixed build process.

96 views
Skip to first unread message

Steven Stark

unread,
Jun 14, 2013, 5:51:58 PM6/14/13
to jangaro...@googlegroups.com
Jangaroo is awesome, but I want a mix of lazy loading and minimized, for very clear reasons:

* over 1/2 my .js files will not be required by the end user.
* turning jangaroo off of debug mode, disabling lazy-loading, can cause errors with some setups ( including mine )
* I have no interest in modifying the jangaroo core code.
* file size can be reduced greatly. I had 2mb of .js, minimized to 638Kb, gziped to 110Kb
* future files can be lazy loaded no problem.

My process:

first, my process requires the web app has been built once. It will use the output files, so that ALL the js will be present.

Next, run the app and look at the generated source in firebug. Find all the loaded .js files as new <script /> tags that have been added by the jangaroo runtime. Filter out of this list files loaded with jangaroo-application, I chose not to include this file in my minification. Only play your game until a point to where you feel makes a good snapshot.

In your POM, add in YUI Complressor for JUST these initial files. see:


Here is my configuration for this:

              <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                  <execution>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                  </execution>
                </executions>
                <configuration>
                    <nosuffix>true</nosuffix>
                    <force>true</force>
                    <nomunge>true</nomunge>
                    <excludes>
                        <exclude>**/*js</exclude>
                        <exclude>**/*.css</exclude>
                    </excludes>
                  <aggregations>
                    <aggregation>
                      <!-- remove files after aggregation (default: false)
                      <removeIncluded>true</removeIncluded>
                      -->
                      <!-- insert new line after each concatenation (default: false) -->
                      <insertNewLine>true</insertNewLine>
                      <output>${project.build.directory}/${project.build.finalName}/static/all.js</output>
                      <!-- files to include, path relative to output's directory or absolute path-->
                      <!--inputDir>base directory for non absolute includes, default to parent dir of output</inputDir-->
                      <includes>
                          <include>${project.build.directory}/${project.build.finalName}/joo/classes/filename.js</include>
                           ...
                          </includes>
                    </aggregation>
                  </aggregations>
                </configuration>
            </plugin>


For some reason YuiCompressor is not minifying my all.js, I don't know it well enough to know why so I add in uglify to do the job. See:


and my setup for this is:

            <plugin>
              <groupId>net.tqh.plugins</groupId>
              <artifactId>uglifyjs-maven-plugin</artifactId>
              <version>1.0</version>
              <configuration>
                 <sourceDirectory>${project.build.directory}/${project.build.finalName}/static</sourceDirectory>
                 <outputDirectory>${project.build.directory}/${project.build.finalName}/static</outputDirectory>
              </configuration>
              <executions>
                 <execution>
                    <phase>prepare-package</phase>
                    <goals>
                       <goal>uglify</goal>
                    </goals>
                 </execution>
              </executions>
           </plugin>


And, of course, in your app HTML load in the new all.js after jangaroo-application, and keep debug mode on.

I am very pleased with the outcome.


The final results:

* Clean then build with new pox additions active: FAILS
* Build without pom changes, THEN add in the changes. ( comment ): SUCCESS
* Keep these pom changes in the parent application, so it will succeed in either case: UNTESTED
* Run the game without YUI Compressor enabled: SUCCESS AND RUNS
* Run the game without Uglify enabled: SUCCESS AND RUNS
* Run the game without and minification: SUCCESS AND RUNS




REQUEST FOR ADDITIONS TO JANGAROO:

* I would very much like to see a 'strip comments' and 'minimize' options directly from the jangaroo compiler. I want to use these lazy loading options, but without the baggage.

Actually, I have a question. If I minimize all the js, named .min.js, will jangaroo know to load the minimized? I saw function params that suggested this is the case. I will test and let you know. :) If so, then there is no issue.. 

* Does jangaroo have any reporting exposed? I would like to know which files have been loaded to create a simple list and automate easier.
Reply all
Reply to author
Forward
0 new messages