There are so many template engines available that discussing the pros and cons of all of them is beyond the scope of this book. Instead I will provide a quick overview of the most common template engines and how to compress a template file.
I strongly believe that there is no such thing as the best JavaScript template engine. Each time you work on a project you have to decide which is the right engine for the job at hand. For instance, underscore.js templates are fast and lightweight and if you want them already loaded in your app then it's a good option. When using jQuery, the natural choice seems to be ICanHaz.js because it returns each template as a jQuery object. When you need a more robust template engine, then Google Closure Templates could be a valid option.
In most cases Mustache completely fits the needs of an application because there is no logic in the templates and because the templates are language-agnostic, allowing you to reuse them between...