DEV Community

Ajmal Hasan
Ajmal Hasan

Posted on

1 1

Improve React Native Android Startup Time by Disabling `.bundle` Compression

There's a simple optimization that can significantly reduce startup timedisabling compression for .bundle files.

🎯 The Optimization

Margelo, a well-known tech company in the React Native ecosystem, recently shared a pro tip:

🚀 Disabling compression for .bundle files can improve launch speed by up to 400ms.

You can apply this optimization by modifying your app/build.gradle file:

android {
    androidResources {
        noCompress += ["bundle"]
    }
}
Enter fullscreen mode Exit fullscreen mode

🔍 How It Works

By default, Android compresses .bundle files, requiring them to be decompressed during runtime. This adds overhead to the app's launch process.

By adding .bundle files to noCompress, we allow Android to load them directly, reducing startup delay.

🏎️ Result: Faster app launch time 🚀


✅ Compatibility

A common concern among developers is:

"Does this optimization work for both the old and new React Native architectures?"

Answer: Yes!

React Native core contributor Marc (mrousavy) confirmed that this works for both architectures, making it a safe and effective improvement for all projects.


⚖️ Trade-Offs: Faster Startup vs. APK Size

While this tweak improves startup performance, there's a small trade-off:

🔴 Slightly Increased APK Size

Since .bundle files are no longer compressed, they take up more disk space in the APK.

However, in most cases, faster launch times outweigh the minimal size increase, leading to a better user experience.


📉 How to Manage APK Size?

If your app size increases significantly, here are some tips:

Reduce unused dependencies in your .bundle file.

Use Proguard and R8 to remove unused code.

Optimize images and assets for better compression.

Enable Hermes for better performance and reduced bundle size.


🚀 Conclusion

If you're looking to optimize your React Native app’s performance, disabling .bundle compression is a quick win.

With just a few lines of code, you can make your app launch faster, giving users a smoother and more responsive experience.

Sentry mobile image

Improving mobile performance, from slow screens to app start time

Based on our experience working with thousands of mobile developer teams, we developed a mobile monitoring maturity curve.

Read more

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay