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.


Source : http://www.visualbis.com/blogs/design-studio/2014/09/10/javascript-compression-for-design-studio-performance/

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

  1. Karol Kalisz

    we have to distinguish between

    1) JS code minification (cut white spaces, line breaks, rename possible lical variables, etc)

    and

    2) http compression for the transfer to the client.


    for 1) Design Studio is already minifying all JS scripts at compilation time – we deliver both, full and minified versions. In production always the minified versions are used. with a url parameter &DEBUG=X this can be changed (works only in local mode and users with admin permissions)


    for 2) this is the content of this blog as mensioned also in the “new feature” part brought by Michael. Actually this is not a Design Studio feature, but we have found out that many servers are not having this ZIPPing in default.

    -> so, you should check if your server is ZIPPing the responses and activate if not.



    (0) 
    1. Mike Howles

      Karol,

      For point 1, “at compilation time” would mean you provide a filename.js and filename-min.js file for the DS JS files, correct?

      And yes my initial leading question was to allude of just what’s mentioned in point 2, gzip or file transfer compression is not implicitly JS minification.

      (0) 
      1. Karol Kalisz

        correct. for point 1, the files *-min.js are included (and loaded when no DEBUG url parameter is available). In addition, in SP1 of 1.3 release many mimes are bound together and send as a “bigger” file, see Design Studio 1.3 Support Package 1 Released and note 2057243.

        and correct for 2, the settings for the GZIP transfer are not minifying the scripts itself (I hope!) – but as those are ZIPPed – this is good for the data transfer itself. In the browser you see again unzipped version.

        shortly, both points are completelly independent.

        (0) 

Leave a Reply