“Hermes is an open-source JavaScript engine optimized specifically for React Native. Unlike browser V8 engines that perform heavy JIT compilation, Hermes compiles JS source code into compact bytecode Ahead-of-Time (AOT) during app build, reducing Time to Interactive (TTI), memory footprint, and APK/IPA binary size.”
Why React Native uses Hermes to compile JavaScript into bytecode at build time instead of JIT compiling on mobile devices.
// android/app/build.gradle (Enabling Hermes Engine)
project.ext.react = [
enableHermes: true, // Compiles JS to HBC bytecode at build time
]
// Startup performance: TTI drops from 1,200ms to 240msBuild step: Hermes compiler (hermesc) parses JavaScript bundle into AST
Emits pre-optimized Hermes Bytecode (HBC) binary file
App startup: Mobile OS maps HBC file directly into virtual memory (mmap)
Engine skips parsing and bytecode generation steps entirely
Initial screen executes in <50ms with a compact generational garbage collector
Memory mapping (mmap) bytecode allows the OS to share and discard clean bytecode pages under memory pressure without killing the app process.