Skip to content

Instantly share code, notes, and snippets.

@rbackhouse
Created March 20, 2011 22:46
Show Gist options
  • Save rbackhouse/878762 to your computer and use it in GitHub Desktop.
Save rbackhouse/878762 to your computer and use it in GitHub Desktop.
Example demonstrating calling the V8 based Javascript optimizer
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