React Native - Does console.log() hurt performance when going to production?

Yaron Levi picture Yaron Levi · Aug 27, 2016 · Viewed 8.5k times · Source

I have a lot of console.log() in my app. Most of them are in catch blocks, so I can clearly see what went wrong when developing. Some are there to log the current time so I can check function execution times.

When deploying to production, those console.log() will run in the client's devices. Can I just leave them as they are? Will they hurt performance/memory or may cause some exception or unwanted behaviors?

Answer

David picture David · Aug 27, 2016

From React Native docs:

Console.log statements

When running a bundled app, these statements can cause a big bottleneck in the JavaScript thread. This includes calls from debugging libraries such as redux-logger, so make sure to remove them before bundling.

So yeah.. I would remove them :)

The ones in your catch statements may be ok to leave in as they only fire if there's an issue (would rather grab more info on that than worry about the performance hit)

There's more performance tips on the react native docs here