Skip to content

Instantly share code, notes, and snippets.

@rbackhouse
Created March 20, 2011 22:35
Show Gist options
  • Save rbackhouse/878746 to your computer and use it in GitHub Desktop.
Save rbackhouse/878746 to your computer and use it in GitHub Desktop.
Example demonstrating calling the Rhino 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.rhino.RhinoJSOptimizerFactory;
private void runRhinoOptimizerNoCompressor() {
ResourceLoader resourceLoader = new FileBasedResourceLoader(new File("/pathToResources"));
RhinoClassLoader rhinoClassLoader = new RhinoClassLoader(resourceLoader);
JSOptimizerFactory factory = new RhinoJSOptimizerFactory();
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();
}
}
@rbackhouse
Copy link
Author

Use the FileBasedResourceLoader from gist 848002

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment