"use strict" only in debug?
I found two opinions about using strict mode in production:
There is no reason to ship “use strict” in your production code. There is no performance gain (verified with V8 team and Brendan a while ago) and I don’t need my users’ VMs doing the extra checks as well. Keep it development only, strip it out during build. This way you also avoid the concatenation issue you reference.
There may not be a performance gain, but there’s also not a performance loss. In production, even more than in development, is where you want to be sure you’re noticing errors. Minimizing the changes between the development and production versions of the code is key to being able to debug issues quickly and efficiently. Yes it helps during development, but there’s no reason to pull it out of production code.
And of course those 12b weight of "use strict" won't change a thing.
The line "use strict"; makes up 13 bytes of your file. I'd suggest that this is unlikely to even approach 1% of your file size.
Use one of the many minifiers out there to reduce your file size, along with gzip comression on the server-side, if you're concerned about bandwidth. Manually removing 13 bytes is a false economy.
Exactly which minifier may depend on your code, but here are some suggestions.
Certainly its a micro-optimization, but if you're concatenating (say 25) JS modules together, thats all of the sudden 250bytes.
Deploying to production in a high traffic application, with say 1000 hits per minute, thats 130+ Gb a year of traffic you can prevent if your build removed the 'use strict';s
I'm sure that would save a few bucks on AWS...
I haven't seen a compelling argument to keep it in production other than its not worth the time. It probably isn't, but if you already have a build system, and the know-how to pull this off with minimal effort, why not?
I would currently recommend that you remove the "use strict" in any code that is intended for production (and just use it in debug).