Understanding Hermes Engine: Features, Advantages, and Performance Evaluation in React Native
Hermes is a lightweight, ahead‑of‑time compiled JavaScript engine bundled with React‑Native for Android that shrinks APK size by about 10 %, cuts memory usage, speeds up startup by roughly 16 %, supports ES6, integrates with existing projects and CodePush, and offers improved debugging despite lacking JIT.
Since the release of Google’s Flutter, Facebook has accelerated the iteration of React‑Native to improve its performance and avoid being outpaced. A major recent move is the open‑source release of the Hermes JavaScript engine, which is now bundled with React‑Native on Android.
What is Hermes?
Hermes is a lightweight JavaScript engine developed by Facebook for React‑Native Android. It uses ahead‑of‑time (AOT) compilation, which reduces memory usage, shrinks the APK size, and improves execution speed.
What is a JavaScript engine?
A JavaScript engine is a virtual machine that parses and executes JavaScript code, typically embedded in web browsers.
Mainstream JavaScript engines
V8 (Google), JavaScriptCore (Apple), SpiderMonkey (Firefox).
JavaScript engines used in React‑Native
Weex: Android – V8, iOS – JavaScriptCore. React‑Native: Android – JavaScriptCore (default) or Hermes/V8; iOS – JavaScriptCore (required by Apple).
Hermes features
Pre‑compiled bytecode for faster engine loading.
No JIT compiler, which reduces engine size and memory footprint (though raw script execution may be slower than V8/JSC).
Garbage‑collection strategies optimized for mobile devices.
Integrating Hermes into an existing project
Upgrade React‑Native and related libraries (low cost).
Migrate the Android project to AndroidX (requires SDK 28+, higher cost).
Modify build.gradle to add Hermes properties and dependencies (low cost).
CodePush compatibility
Hermes produces a binary index.android.bundle instead of a plain JavaScript file, but the loading mechanism remains unchanged, so CodePush can still be used. However, the code‑push release‑react command does not generate the pre‑compiled bundle; the standard code‑push release works.
Debugging
In Debug mode Hermes disables AOT to support Hot Reload, so performance gains disappear. Debug builds include libhermes‑inspector.so for Chrome inspection, offering a better DevTools experience than the default RN debugger.
ES standard support
Hermes supports ES6 and follows the latest JavaScript specifications, but omits rarely used features such as eval() to keep the engine small.
Performance evaluation
Package size : JSC release APK ≈ 20 MB, Hermes release APK ≈ 18 MB (≈10 % reduction). The size reduction mainly comes from a smaller libhermes.so compared to libjsc.so .
Memory usage : Average memory drops from 210 MB (JSC) to 190 MB (Hermes), a ≈10 % reduction, primarily due to the smaller native library.
Time‑to‑Interactive (TTI) : JSC TTI ≈ 829 ms, Hermes TTI ≈ 694 ms, a reduction of 135 ms (≈16 %).
Conclusion
Facing strong competition from Flutter, React‑Native has introduced Hermes, a mobile‑focused JavaScript engine that delivers measurable improvements in APK size, memory consumption, and startup latency. The article aims to help developers understand Hermes and decide whether to adopt it.
Didi Tech
Official Didi technology account
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.