Projects:Add JavaScript Engine/Specs
Technical Specification
New JS Engine
A new JS engine must be chose because Nashorn has been deprecated since Java 11 and is removed in Java 15. Those are the main criteria:
- It has to be smaller, not too much dependencies
- Scope is small, not used extensively(no need for full ECMAScript 6 support)
- If possible, should be easily pluggable into Java ScriptEngine API
With those criteria, 3 options have been considered:
- GraalVM
* It is used in Discount Engine * Full ECMAScript 6 support * Very big and has too much dependencies
- V8, Google's JS engine
* Used in Node.js, chromium and electron * Full ECMAScript 6 support * Needs native libraries for different OS (cumbersome for multi-platform)
- RhinoJS, Mozilla's Open-source JS engine
* Started to regain community traction after Nashorn removal * Small library and no dependencies * Integrates with Script Engine API * Has no full support for ECMAScript 6, some features are missing
RhinoJS has been chosen following the criteria previously mentioned. It works well for this small scope.
Removal of other Rhino jars(yuicompressor)
Yui-compressor is a library that was being used previously to compress old(version <=2.5) JavaScript. It also compressed some CSS, but this was not working correctly.
In the scope of this project it is removed and substituted by JSMin, that does a similar job, although with 20% less compression ratio.
- Yui-compressor ratio = ~1.8
- JSMin compression ratio = ~1.5
- Both have similar compression ratio after Apache gzip compression