Google Closure Introduction
Posted: August 27, 2011 Filed under: Closure Compiler, Closure Library, Closure Templates, General | Tags: Closure Compiler. Closure Templates, Closure Inspector, Closure JavaScript, Closure Library, compilador closure, ejemplos closure, libreria Closure, Plantillas closure, que es google closure, uso closure 1 Comment »¿What’s Google Closure?
Google Closure, is a set of individual JavaScript tools that are also designed to help developers build complex web applications, and is used by Gmail, Google Maps, and Google Docs.
Google Closure is made basically of three important tools.
The compiler, Closure Compiler, is a JavaScript optimizer that compiles web apps down into compact, high-performance JavaScript code.

The compiler removes dead code, comments, documentation, for example, and minimizes the code rewriting expresions and function’s names, making JavaScript code smaller and faster on browser’s JavaScript engines.
Also checks syntax, variable references, and types, and warns about other common JavaScript pitfalls.
JavaScript code example:
/**
* @param {string} name
*/
var hello = function(name) {
alert('Hello, ' + name);
};
hello('New user');
The compiler would produce the following output equivalent to the previous:
alert("Hello, New user");
Executing either code snippet will have the same effect: an alert box with the text “Hello, New user”. However, the code generated by the compiler is more concise, so it can be downloaded, parsed, and executed faster.
The compiler can be used according to the needs or tastes of individual developers, there is a command line tool to run the compiler and compile and optimize your JavaScript code.
Also, there is a web application.You can paste your JavaScript code on a text box and clic compile to do your code minimize.
There are also several extensions thar allow us to improve our work with the compiler. One of them is Page Speed; With Page Speed you can see the performance benefits for your web pages.
The other one is Closure Inspector, it is an extension for FireBug FireBug, a most useful tool for any web developer
working with JavaScript.
Another of the tools that make Google Closure is the library Closure Library, is a broad, well-tested, modular, and cross-browser JavaScript library. It is much more than a simple set of functions to make cool animations on our web pages, really It’s a JavaScript development framework.
Web developers can pull just what they need from a wide set of reusable UI widgets and controls, as well as lower-level utilities for the DOM, AJAX and JSON, server communication, animation, data structures, unit testing, rich-text editing, and much, much more. Check by yourself on JavaScript library documentation.
This library has been designed to maximize the compiler features and optimizations. You can make your project big and complex (with namespacing and type checking), yet small and fast over the wire (with compilation).
The last tool of Google Closure are the templates,Closure Templates, a templating system for dynamically generating HTML in both Javascript and Java. Closure templates have a simple syntax that is natural for programmers.
Later I’ll post how to downloading and installing the Closure tools and We’ll develop our first example.
References:
:: Gooogle Code
:: Google Closure Library
:: Closure: The definitive Guide, Michael Bolin

Google Closure Introduction (googleclosure.wordpress.com)