Tuesday, October 2, 2012

Disable minimizing the resources when using wro4j


After implementing the wro4j in my application, the performance of the pages improved but there was one problem. Now because all the resources are minified, it become difficult to debug the Javascript issues from Firebug. 
I resolved the above issue by following below steps:

1. Extending the "DefaultGroupExtractor" class and overriding only one method :
/*
* Never minimize the resources
*/ 

@Override
  public boolean isMinimized(HttpServletRequest request) {
    return false;
  }
2.  Extending the "BaseWroManagerFactory" class and setting new group extractor as created in step 1:
/*
* Return the custom extractor as created above.
*/
  @Override
  protected GroupExtractor newGroupExtractor() {
    return new CustomDefaultGroupExtractor(); // extractor created in step 1
  }
3. In the wro.properties file add the manager factory class as below:
managerFactoryClassName=com.vmops.web.optimizer.CustomWroManagerFactory

4. Restart the server. Now you will see no resources are minimized.

~Manish

No comments:

Post a Comment