Make large JavaScript files (such as RAMP session files) smaller

This forum allows developers to post programming tips and coding techniques that may be useful to other Visual LANSA developers. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Pablo
Posts: 48
Joined: Wed Dec 02, 2015 10:35 am

Make large JavaScript files (such as RAMP session files) smaller

Post by Pablo » Wed May 24, 2017 11:04 am

To make large JavaScript files (such as RAMP session files) smaller so that they download faster you can potentially minify them
There are many tools that can minify JavaScript files, for example https://www.devsaran.com/blog/10-best-j ... ying-tools
Following is an example of minification using the Google Closure compiler.
• Open a Command Prompt and type Java to invoke Java.exe. You should see a list of Java options displayed. If Java.exe cannot be found download and install Java first. Then repeat this test.
• Create folder c:\temp if you don’t have one already.
• Download the Google Closure compiler from https://dl.google.com/closure-compiler/ ... latest.zip
• Extract closure-compiler-vYYYYMMDD.jar from the download zip file into folder C:\temp.
• Rename it to be compiler.jar
• Copy your JS file to be min[/b]ified into folder c:\temp. Change its name to testinput.js
• Open a Command Prompt. Change to directory c:\temp
• Copy and paste the following entire and complete command into Command Prompt window:

Java -Xmx512m -jar compiler.jar --compilation_level WHITESPACE_ONLY --js testinput.js --js_output_file testoutput.js --warning_level VERBOSE

The command should look like this:
CommandPromptScreenCapture.png
CommandPromptScreenCapture.png (8.82 KiB) Viewed 2570 times
• Press enter. The Google closure compiler should then execute and strip all white space from the testinput.js file and create new file named testoutput.js.
In theory, the minified output file can be used as a direct replacement for the input file, but you should test this.
More information at https://developers.google.com/closure/c ... tarted_app

Post Reply