UglifyJS performance

Austin Jackson themacphage at
Mon Dec 15 03:15:58 UTC 2014

Hello! I’m Austin and I like Nashorn.

I was prompted by @lagergren <> to share something with you all that might be of use. I love the work that you all have done with Nashorn making it easy to write JavaScript code and utilize standard Java classes — it’s absolutely great!

I, personally, have been using Nashorn to try and run NodeJS modules under it, particularly UglifyJS2.

All the files I mention following this are available in a Github release below of my app I’m hoping to use Nashorn with. There is a executable Jar file with the correct directories and instructions on how to run on the website below. The source code is available here below, also.

My app is currently a test that wraps UglifyJS2 with bindings in You can ignore the LESS stuff because that runs on Rhino and isn’t my library (it’s here <>).

The important thing is that when I run UglifyJS2 natively under NodeJS (V8), then the compile time is around 1 second more or less (I had no way to time it, that I knew of), but when I run my wrapper, it takes around 47.5 seconds to do the same! However, the resulting copies are verbatim and Nashorn functioned entirely correct, just a big performance problem. @lagergren <> said this might be a warm-up issue.

For clarity, I’m running what I believe to be the newest public release of the JDK/JRE. I’m on OS X Yosemite. When I run java -version I get this:

java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Github release: <>
Binaries (direct ZIP): <>
Source code (direct ZIP): Source code (zip) <>
Github source code at specified commit: <> 

If you have any more questions regarding my setup, please tweet me @au5ton <> or email themacphage at .


Austin Jackson 
themacphage at <mailto:themacphage at>

More information about the nashorn-dev mailing list