Closure Tools are a set of utilities used for web development. It is mainly supported by Google, but is open source under the Apache License Version 2.0, a well-established permissive license. The name Closure Tools hides under it a lot of subtools, which will make your life as an apprentice developer easier. It includes a JavaScript optimizer, a JavaScript library, a templating library, a style checker and style fixer, and at last, a stylesheet language. Just to illustrate how powerful this set can be, think that most Google JavaScript applications, such as Gmail or Google Maps, use these components.
Why are we introducing you to these tools?
The OpenLayers 3 library itself depends on the Closure Library, the JavaScript library attached to Closure Tools. Its main goal is to leverage cross-browser support. You also know you can write your application in pure JavaScript.
However, you can also consider Closure for advanced uses like creating your own component such as controls and buttons with special behavior inherited from an existing OpenLayers component. You will also get some useful UI components. It is also a good toolset to achieve better file compression when you want an efficient web mapping application, using the Closure Compiler, another utility from the Closure Tools bundle.
We will not review all Closure Tools but only the most useful. Specifically, we will cover the following topics:
If you have ever done a bit of web development, and in particular, JavaScript, you must have heard about jQuery, the most popular JavaScript library with more than 50 percent of the worldwide websites using it. To not reinvent the wheel, the OpenLayers development team chose Closure Library rather than jQuery. Why was this decision made? For a better understanding, you need a bit of history of the Web.
In the olden days, there wasn't a lot of JavaScript. All applications were created using simple HTML and CSS. There was dynamic content when reloading a full page using a server-side such as PHP or Java. However, people wanted a smoother web navigation experience. With the way AJAX works it was possible, as illustrated in the following figure, and people began to focus more and more on the client-side:

The main two problems associated with this evolution are:
When you are at home, you don't really suffer from bandwidth restriction, but in other cases, you will always suffer from high latency. If you are planning to work on mobile support with limited bandwidth, high latency, and a browser with limited memory, it can be a pain.
A good part of the solution lies in compression.
You have three levels of compression available for JavaScript, depending on technology:
For performance, the last method will work the best, and the Closure Library is the only JavaScript library able to work this way, when combined with Closure Compiler.
Closure Tools, in particular, Closure Library and Closure Compiler are among the best tools to deal with this case.
Although both tools are tightly related, we will review the most useful functions related to Google Closure Library and later explain how to use Closure Compiler to optimize code.