So in my JavaScript codebase I have been using the var me = this idiom to support minification. But I’ve started questioning this lately, and I was wonder if assignment of this to a variable could be avoided with smarter minification tools?
It seems like a tool should be able to detect functions where creating a variable to represent this would save characters over multiple calls to this. The same could be done for boolean values, like var yes = true, nope = false.
Are there tools I could use to avoid setting var me = this all over my code base? In general is a good idea to change your codebase to better support minification?
Keep in mind that I do understand that in certain instances I need a variable assigned to this to reference outer scope inside a JavaScript closure. The use of var me = this I am taking about is solely for supporting minification.
You should not worry about minification until you are ready to deploy your code live. I would recommend using Google’s closure compiler to minify all of your code once you are done. Check it out here: http://code.google.com/p/closure-compiler/