You're not writing clear, easily understandable code for you -- you're doing it for the person who comes in after you leave and has to pick up where you left off. The same goes for documentation, so be considerate. Remember, there's a selfish benefit, too, when working on longer projects and your memory of what you did early on fails you.
Minification, obfuscation, and concatenation
Now that your code is linted, tested, and documentation has been generated, it's time to optimize your app for the end-user. Minification and obfuscation will reduce your overall payload size, while concatenation will decrease the number of HTTP requests needed. The two together boost user experience by improving load times, which is critical for user retention on the Web.
Minification removes all unnecessary characters from your code, such as comments and extra white space. Next, obfuscation renames your identifiers to the bare minimum. I know you think
prepareTextForPosting is a nice, descriptive function name, but
sQ will do just fine for the interpreter. This can shave off quite a few bytes depending on the length of your identifiers.
mangle property set to
true. Since I'm using Grunt already, I'm using the concatenation plug-in built by the Grunt team.
Now stop reading this article and go assess your own front-end stack. Check out some of the links included and start playing with the technologies that are new to you. Lay down a strong foundation for your projects, so they can support you throughout the entire development cycle. Remember, it's less about the individual items you implement and more about attentiveness to your workflow. Even if you just set up Grunt and start linting your code, you'll be in much better shape than before -- and it will be much easier to adopt other optimizations.
This article, "Web app coders: Clean up your act!," was originally published at InfoWorld.com. Keep up on the latest developments in application development, and read more of Andrew Oliver's Strategic Developer blog at InfoWorld.com. For the latest business technology news, follow InfoWorld.com on Twitter.