After exploring other options, we built a new JavaScript engine we call Hermes. It is designed to improve app performance, focusing on our React Native apps, even on mass-market devices with limited memory, slow storage, and reduced computing power.

As mentioned, Hermes focuses on three metrics: the time an app requires to become usable (time to first interaction, TTI), app download size (APK size), and memory utilization. Facebook described three major architectural decisions they made to improve those metrics: precompiling the JavaScript source code, ditching the JIT compiler, and adapting garbage collection to mobile OSes constraints.

Precompiling JavaScript into bytecode brings two key benefits to performance. On the one hand, moving ahead parsing and compilation directly reduces the time spent for those tasks at launch time. On the other hand, since the precompilation phase has more relaxed time constraints, generated bytecode is usually smaller and more efficient and the compiler can apply whole-program optimizations such as function deduplication and string table packing. On the bytecode-format front, Hermes bytecode can be mapped into memory without requiring to read the whole file in advance, which brings a significant improvement with slow flash memories and reduces the change of an app being killed by the OS due to excessive memory usage.

(Image from Facebook blog)

Additionally, Facebook maintains, a JIT compiler is optimized for CPU-intensive workloads that are not typical of mobile apps. Thus not using one does not exact a significant toll while shrinking warm-up time along with native code size and memory consumption.

As a final performance optimization for mobile apps, Hermes uses a garbage collection strategy aimed to minimize the chance that an application is killed by a mobile OS due to its memory usage. Hermes garbage collector thus attempts to reduce the overall virtual memory consumption by implementing on-demand allocation in non-contiguous chunks that can be moved around and returned to the OS when no longer needed.

Facebook is not targeting its new JavaScript engine as a general replacement to V8, which they still deem to be the most appropriate for Node and browser-based apps. It is worth noting that iOS apps are bound to use exclusively the JavaScript engine included in the iOS SDK, so they cannot benefit from Hermes optimizations.