Introduction: Why Cold Start Speed Matters
When users launch a mobile application, they expect fast loading times. A cold start refers to the initial launch of an app when the code must be loaded into memory, initialized, and run for the first time.
In React Native, the Hermes JavaScript engine was introduced to optimize app performance, particularly during cold starts. Since its release, Hermes has become a popular choice for improving app performance by significantly reducing the memory footprint and enhancing startup speed.
What is Hermes and Why Does It Matter?
Hermes is a lightweight, high-performance JavaScript engine built specifically to enhance React Native app development. Key optimizations include:
- Ahead-of-Time (AOT) Compilation: Hermes compiles JavaScript code into bytecode during the build process, eliminating runtime interpretation.
- Memory Efficiency: Optimized to use less memory, reducing the load on initial startup time.
- Smaller JavaScript Bundles: By compiling to bytecode ahead of time, Hermes generates smaller JS bundles, reducing data loaded at startup.
1. Enable Hermes for Release Builds
Ensure Hermes is actively configured in your Android and iOS builds:
- Android: Set
enableHermes: trueinproject.ext.reactconfiguration in build.gradle. - iOS: Set
config[:hermes_enabled] = truein your Podfile configuration.
2. Leverage AOT Compilation
Hermes AOT compilation compiles JavaScript into bytecode before launch, reducing cold start time by avoiding runtime parsing. Ensure you are running Hermes in release mode, as AOT is available in this configuration. In debug mode, Hermes uses JIT compilation, which may result in slower startup times.
3. Reduce Bundle Size
- Tree Shaking: Eliminate unused JavaScript code during the bundling process.
- Lazy Loading and Code Splitting: Break your app into smaller chunks and load only necessary code on initial launch.
- Remove Debugging Code: Exclude all development-only code from production builds using Metro bundler configurations.
Transform Your Publishing Workflow
Our experts can help you build scalable, API-driven publishing systems tailored to your business.
4. Optimize Memory Usage with Hermes Flags
Hermes provides configuration flags to fine-tune memory usage. For example, set low-memory mode:
hermesFlags: ["--low-memory"]
This reduces memory overhead during startup, leading to faster cold starts, especially on lower-end devices.
5. Preload Hermes Bytecode
Preloading Hermes bytecode allows the app to load precompiled JavaScript bytecode before full startup, bypassing some initialization steps and reducing cold start time. Enable with hermesPreload: true in your build configuration.
6. Optimize Native Modules
- Use TurboModules: TurboModules in the new React Native architecture allow asynchronous loading and initialization of native modules, improving cold start speed.
- Lazy Load Native Modules: If certain native modules are not needed immediately, ensure they are lazy-loaded after the initial cold start.
Conclusion
React Native's Hermes engine offers powerful optimizations for cold start performance. Key actions include enabling Hermes for release builds, leveraging AOT compilation, optimizing bundle size, using memory flags, preloading bytecode, and optimizing native modules with TurboModules.




