If you’re using a JS Minifier for your module files (and you probably should), there are some important compilation options you need. Many minifiers obfuscate and optimize variables inside of functions, which will affect the ability of inject to identify your dependencies before runtime. For the greatest in-browser optimization, we recommend using UglifyJS since it allows you to protect specific reserved names while still mazimixing the amount of compression you can do. If running node isn’t an option, YUI and Google compressors can also be used with the following options:
- YUI Compressor:
- Google Closure:
If your compression engine of choice isn’t on the list, and has the ability to protect/preserve certain names, send us a bug with the settings and we’ll add it to the list. As a last ditch effort, you can often put an
eval(); after your return statement. For most optimizers, the addition of an eval will prevent variable munging within the current scope chain.