Software:Google Closure Tools
Original author(s) | |
---|---|
Initial release | November 5, 2009[1] |
Written in | Java |
Available in | JavaScript |
Type | Ajax framework |
License | Apache License 2.0 |
Website | developers |
Google Closure Tools[2] is a set of tools to help developers build rich web applications with JavaScript. It was developed by Google for use in their web applications such as Gmail, Google Docs and Google Maps.[3] As of 2023, the project had over 230K LOCs not counting the embedded Mozilla Rhino compiler.
Closure Compiler
The Closure Compiler is a tool for making JavaScript downloads run faster, at the expense of human readability. It does not compile from JavaScript to machine code, but rather compiles from JavaScript to more efficient JavaScript.
It parses JavaScript, analyzes it, removes dead code and rewrites and minifies what is left. It also checks syntax, variable references, and types and warns about common JavaScript pitfalls.
It supports transpiling modern ECMAScript code to ECMAScript 5, so that programmers can write JavaScript that uses new ECMAScript features, and run it in browsers or other environments that do not yet support them. This obviated Traceur Compiler, another project that supported transpiling ES6 to ES3.[4]
The Closure compiler also supports type checking via type annotations that must be written in JSDoc comments.[5]
CLI
Google provides a command line tools used to optimize and compile .js
files:
- Java-based application run from shell which compiles a list of specified JavaScript files
- npm package
google-closure-compiler
which provides three compilers: native binary executable (via GraalVM), Java and a JavaScript-based one.
Closure Compiler Service
The Closure Compiler Service application provides a form for a user to input a URL pointing to a JavaScript source or enter JavaScript source code in a text box. The website will display with the optimized JavaScript on right side for the user to copy.[6]
Users can also call the Closure Compiler Service API directly. The service accepts HTTP POST requests, with parameters including the string of JavaScript to be optimized (or a URL pointing to it), the optimization level, whether to include errors and warnings, and the output format (JSON, XML, or text).
The service is marked as deprecated and will eventually be removed.[7]
Ecosystem
Programming languages that transpile to JavaScript benefit from Closure Tools. For example, Closure Compiler helps to make ClojureScript practical by making the compiled JavaScript code more efficient.[8]
Internals
Closure Compiler is build upon modified version of Rhino JS engine build by Mozilla, Google Guava, a Java standard library, Protocol Buffers, Gson and various others tools for testing. It also ships with built-in javascript JSDoc annotations for various popular projects like Node.js's standard API library, JQuery, Google Map APIs etc..
Closure Library
The Closure Library is a JavaScript library, written specifically to take advantage of the Closure Compiler, based on a modular architecture. It provides cross-browser functions for DOM manipulations and events, Ajax and JSON, as well as more high-level objects such as User Interface widgets and Controls.
Closure Templates
Closure Templates are a templating system for dynamically generating HTML in both Java[9] and JavaScript.[10]
Because the language was apparently referred to as "Soy" internal to Google, and "Soy" remains in some of the documentation and classes,[11] sometimes Closure Templates are referred to as "Soy Templates".
Closure Stylesheets
Closure Stylesheets provided extensions to CSS, which are transpiled to ordinary CSS. Internally in Google, this extended version of CSS is referred to as GSS.
As of November 2021, Closure Stylesheets has been deprecated in favor of tools such as Sass and PostCSS.[12]
See also
References
- ↑ "Introducing Closure Tools - The official Google Code blog". 5 November 2009. http://googlecode.blogspot.com/2009/11/introducing-closure-tools.html.
- ↑ Bolin, Michael, "Closure: The Definitive Guide", O'Reilly Media Inc., Sebastopol, CA, 2010
- ↑ "FAQ - Closure Tools". https://developers.google.com/closure/faq.
- ↑ "Traceur is a JavaScript.next-to-JavaScript-of-today compiler". https://github.com/google/traceur-compiler.
- ↑ "Annotating JavaScript for the Closure Compiler". https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler.
- ↑ "Closure Compiler Service". https://closure-compiler.appspot.com/home.
- ↑ "Closure Compiler Service API Reference". https://developers.google.com/closure/compiler/docs/api-ref.
- ↑ "Motivations for using Google's Closure Tools". https://github.com/clojure/clojurescript/wiki/Google%20Closure.
- ↑ "Hello World Using Java". https://github.com/google/closure-templates/blob/master/documentation/codelabs/helloworlds/helloworld_java.md.
- ↑ "Hello World Using JavaScript". https://github.com/google/closure-templates/blob/master/documentation/codelabs/helloworlds/helloworld_js.md.
- ↑ "Google Code Archive - Long-term storage for Google Code Project Hosting.". https://code.google.com/archive/p/closure-templates/source.
- ↑ Weizenbaum, Natalie (2021-11-01). "Officially mark this repository as end-of-life". https://github.com/google/closure-stylesheets/pull/151/files.
External links
Original source: https://en.wikipedia.org/wiki/Google Closure Tools.
Read more |