Created
March 20, 2011 22:46
-
-
Save rbackhouse/878762 to your computer and use it in GitHub Desktop.
Example demonstrating calling the V8 based Javascript optimizer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.dojotoolkit.optimizer.JSAnalysisData; | |
import org.dojotoolkit.optimizer.JSOptimizer; | |
import org.dojotoolkit.optimizer.JSOptimizerFactory; | |
import org.dojotoolkit.optimizer.Localization; | |
import org.dojotoolkit.optimizer.v8.V8JSOptimizerFactory; | |
import org.dojotoolkit.server.util.resource.ResourceLoader; | |
import org.dojotoolkit.server.util.rhino.RhinoClassLoader; | |
private void runV8OptimizerNoCompressor() { | |
ResourceLoader resourceLoader = new FileBasedResourceLoader(new File("pathToResources")); | |
RhinoClassLoader rhinoClassLoader = new RhinoClassLoader(resourceLoader); | |
JSOptimizerFactory factory = new V8JSOptimizerFactory(); | |
JSOptimizer optimizer = factory.createJSOptimizer(resourceLoader, rhinoClassLoader, true, null); | |
JSAnalysisData analysisData; | |
try { | |
analysisData = optimizer.getAnalysisData(new String[] {"dijit.layout.TabContainer"}); | |
for (String dependency: analysisData.getDependencies()) { | |
System.out.println("["+dependency+"]"); | |
} | |
for (Localization l : analysisData.getLocalizations()) { | |
System.out.println("Localization : "+l.bundlePackage+" | "+l.modulePath+" | "+l.bundleName); | |
} | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment