JavaScript compression is a code compression mechanism that allows us to compress and minify JavaScript files. In the programming world, this compression mechanism is called “Code Minification”. In JavaScript, it is achieved by removing extra white space, comments and unwanted characters. The size of the file will be reduced by 30%-80%. However, the functionality of the code remains unaltered despite aggressive compression.
In Design Studio, SAP supports JavaScript compression from version 1.3 SP01. With this new feature, we can achieve the following performance enhancements.
- Quicker load time of dashboards due to compressed scripts
- Reduced Bandwidth consumption of the server
- Reduced HTTP traffic – Since the JS files are compressed and packed together, they are downloaded to client in minimal requests. This reduced traffic improves server response time.
- Faster performance of the JS executor – Since unwanted white space, comments and characters are removed, the JS executor performs faster.
Steps to enable JavaScript compression
Step 1:
Stop the Apache Tomcat server. If Tomcat is deployed across multiple nodes, stop all Tomcat servers.
Step 2:
Open the “InstallPath\SAP BusinessObjects\tomcat\conf\server.xml” file and search for the connector port tag.
Step 3:
Under the connector port tag the following attributes are available – noCompressionUserAgents and compressableMimeType.
- noCompressionUserAgents – Specifies the compression agents available in the system
- compressableMimeType – Specifies the MIME types that can be used for compression
Step 4:
Add ‘application/javascript’ at the end of the compressableMimeType attribute values. This will enable JavaScript compression.
Step 5:
Apply these settings in all Tomcat servers. If deployed across multiple nodes, start all the Tomcat servers.
This compression would be help in a production environment where the application loading time is critical. Reduced size of the application would help in improved load time and server throughput.