Skip to content

Files

Latest commit

c1cfd60 · Oct 21, 2019

History

History
68 lines (45 loc) · 2.38 KB

hermes.md

File metadata and controls

68 lines (45 loc) · 2.38 KB

Hermes - JavaScript Engine for React Native

What is hermes?

Hermes is a JavaScript engine designed for Android platform by Facebook Engineers on July 21, 2019. It’s a small and lightweight optimized for running React Native on Android.

Important Note: This technology only use after react-native 0.60.4 version.

How does it work?

Traditional Javascript engines compile the code after the application is installed. So it compiles bytecode by compiling javascript codes during runtime. This causes delays in application startup.

Hermes Engine Gif

Hermes generates bytecode during the creation of the application. There will be plenty of time to make this process more efficient.

What are the benefits?

  • Shortens the initial opening time of the application.
  • Reduces the size of the application apk(on Android, APK size)
  • Provides efficient memory usage.
  • It can be easily integrated.

Hermes Engine Stats

Why is it designed only for the Android platform?

Because Hermes is optimized for mobile apps, facebook engineers say that "we do not have plans to integrate it with any browsers or with server infrastructure such as Node.js. Existing JavaScript engines remain preferable in those environments."

Why cannot use in iPhones(iOS)?

Apple, requires the use of V8 JavaScript engine on their devices. For this reason, custom Javascript engines can be used on the Android platform.

How to use Hermes?

// android/app/build.gradle,

  project.ext.react = [
      entryFile: "index.js",
-     enableHermes: false
+     enableHermes: true
  ]

Also, if you're using ProGuard, you will need to add this rule in proguard-rules.pro :

-keep class com.facebook.hermes.unicode.** { *; }
// You must clean and rebuild after can the gradle files.

  cd android && ./gradlew clean

Note: If you do not clean up your project after making changes, your application may experience a constant crash during the opening.

That's it! Last step for starting your app:

  react-native run-android

For more details:

android-developers

Resources: