Page 1 of 1

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

Posted: Wed May 24, 2017 11:04 am
by Pablo
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 2512 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