Chapter 12. Using the Compiler

The primary objective of the Closure Compiler is to reduce the size of JavaScript code. Doing so can save money by cutting down bandwidth costs and can increase user satisfaction by accelerating startup times. Although the techniques the Compiler uses to achieve these savings are complex, integrating the Compiler into your build process is not difficult.

Discussion of the Compiler is spread out over three chapters. Each chapter introduces techniques for tuning the Compiler to get smaller output, and subsequent chapters introduce more sophisticated techniques than the previous ones. Specifically, Chapters 13 and 14 contain some of the most challenging material in this book, so make sure you are completely comfortable with each chapter before moving on to the next.

Fortunately, the material in this chapter is fairly straightforward, and it is still possible to get a lot out of the Compiler without mastering the following two chapters. This chapter will teach you how to use the Closure Compiler to minify JavaScript and will introduce some of its basic options. It will also help you make the Closure Compiler part of the build process for your own application.

Once you are comfortable using the Compiler as part of your workflow, you should read the next chapter on advanced compilation. If you have mastered all of the available options in the Compiler and want to use it as the basis of your own JavaScript tools, or you want to access hidden features of the ...

Get Closure: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.