What Is QuickJS
QuickJS is a small and embeddable Javascript engine. It supports the ES2020 specification including modules, asynchronous generators, proxies and BigInt. More features can be found here.
Why would I choose QuickJS for React Native
Based on the performance results on large-scale real-world react-native application and its main features. QuickJS is suitable for some scenarios and not for the others. Besides my humble opinions as follows, you could try using QuickJS to run javascript in ReactNative yourself by adding a few lines of codes in your application to see the results in your cases.
- On Android, QuickJS is slower than V8 in most of my tests. Although it has advantages in memory and binary size which is important on some resource-limited devices. Also QuickJS is benefit from its startup time for some simple bundles.
- On iOS, QuickJS simply better than JSC with code cache and worst than JSC without code cache.
- QuickJS is easy to customize when it compared with V8 or Hermes. Like adding some high performance builtin functions or customized classes. It depends on your business.
- Currently QuickJS have no inspector. But it seems some open source projects have made it worked. Anyway it needs extra works to support inspector in the future.
Performance Result
Real world bundle performance
- We tested QuickJS/V8/JSC with an online bundle size of 1.43M.
- On Android, we enabled code cache for both QuickJS and V8. For TTI, QuickJS is 5-20% slower than V8. For PSS memory, QuickJS is 40-(-5)% lower than V8.
- On iOS, TTI using QuickJS is 15% slower than JSC without code cache. With code cache, QuickJS is 15% faster than JSC and 50% lower than JSC in footprint memory usage.
ESx Compatibility
As listed on official QuickJS website. QuickJS passed 82% of ECMA-262 tests. Meanwhile V8 passed 86% and JSC passed 85% in 2022. If internationalization tests which accounts for nearly 3% are excluded, QuickJS is fairly close to V8 and JSC. You can checkout https://test262.report/ for failed cases just in case.
Github
If there are any further questions, welcome to communicate at https://github.com/bojie-liu/react-native-quickjs.
Top comments (0)