Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Google Closure Tools

From Wikipedia, the free encyclopedia
JavaScript developer toolkit
This articlecontainspromotional content. Please helpimprove it by removingpromotional language and inappropriateexternal links, and by adding encyclopedic text written from aneutral point of view.(October 2019) (Learn how and when to remove this message)
Google Closure Tools
Original authorGoogle
Initial releaseNovember 5, 2009[1]
Final release
v20230802[2] Edit this on Wikidata / 2 August 2023; 2 years ago (2 August 2023)
Repository
Written inJava
Available inJavaScript
TypeAjax framework
LicenseApache License 2.0
Websitedevelopers.google.com/closure/Edit this at Wikidata

Google Closure Tools[3] was a set of tools built with the goal of helpingdevelopers optimize richweb applications withJavaScript. It was developed byGoogle for use in theirweb applications such asGmail,Google Docs andGoogle Maps.[4] As of August 1, 2024 the Closure Library has been sunset, for not "meeting the needs of modern JavaScript development".[5]

Closure Compiler

[edit]

The Closure Compiler is a tool that attempts to compress and optimize JavaScript code, at the expense ofhuman readability. Unlike an actualcompiler, it does not compile from JavaScript tomachine code but rather minifies JavaScript.

The process executes the following steps:

  1. Parses the submitted JavaScript
  2. Analyzes the JavaScript
  3. Removes any dead code
  4. Rewrites andminifies what is left

It also checkssyntax,variablereferences, andtypes and warns aboutcommon JavaScript pitfalls.

It supportstranspiling modernECMAScript code to ECMAScript 5 to achieve a wider range ofbrowser compatibility, similar toBabel. This obviated Traceur Compiler, another project that supported transpiling ES6 to ES3.[6]

The Closure compiler also supportstype checking viaJSDoc type annotations.[7]

CLI

[edit]

The Closure Compiler is available for use throughcommand line tools:

  • Java-based application run from the shell which compiles a list of specified JavaScript files
  • npm packagegoogle-closure-compiler which provides three compilers: native binary executable (viaGraalVM), Java and a JavaScript-based one

Closure Compiler Service

[edit]

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 the compiled JavaScript on the right side for the user to copy.[8]

An API is available, accessible viaPOST requests, parameters include:

  • The JavaScript to be optimized, or a URL pointing to it
  • Optimization level
  • Emit errors and warnings
  • Output format i.e. JSON, XML, or text

The service is marked as deprecated and will eventually be removed.[9]

Ecosystem

[edit]

Programming languages that transpile to JavaScript can use the Closure Compiler in their toolchain. For example, the Closure Compiler is used inClojureScript to optimize the compiled JavaScript.[10]

Internals

[edit]

Closure Compiler is built upon a modified version of theRhino JS engine built by Mozilla,Google Guava, a Java standard library,Protocol Buffers, Gson and various other tools for testing. It also ships with built-in JavaScriptJSDoc annotations for various popular projects like Node.js' standard API library, JQuery, and Google Map APIs.

Closure Library

[edit]

The Closure Library is aJavaScript library, written specifically to take advantage of the Closure Compiler, based on amodular architecture. It providescross-browser functions forDOM manipulations andevents,Ajax andJSON, as well as more high-level objects such asUser Interface widgets and Controls.

Closure Templates

[edit]

Closure Templates are atemplating system for dynamically generatingHTML in bothJava[11] andJavaScript.[12]

Since the language is apparently referred to as "Soy" internally by Google, and "Soy" remains in some of the documentation and classes,[13] sometimes Closure Templates are referred to as "Soy Templates".

Closure Stylesheets

[edit]

Closure Stylesheets provide extensions toCSS, 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 have been deprecated in favor of tools such asSass andPostCSS.[14]

See also

[edit]

References

[edit]
  1. ^"Introducing Closure Tools - The official Google Code blog". 5 November 2009.
  2. ^"v20230802: RemoveUnusedCode: log reasons for not removing variables". 2 August 2023. Retrieved4 August 2023.
  3. ^Bolin, Michael, "Closure: The Definitive Guide", O'Reilly Media Inc., Sebastopol, CA, 2010
  4. ^"FAQ - Closure Tools".Google Developers.
  5. ^"Closure Library is in Maintenance Mode".
  6. ^"Traceur is a JavaScript.next-to-JavaScript-of-today compiler".GitHub.
  7. ^"Annotating JavaScript for the Closure Compiler".GitHub.
  8. ^"Closure Compiler Service".
  9. ^"Closure Compiler Service API Reference". Retrieved2023-07-18.
  10. ^"Motivations for using Google's Closure Tools".GitHub.
  11. ^"Hello World Using Java".github.com.
  12. ^"Hello World Using JavaScript".github.com.
  13. ^"Google Code Archive - Long-term storage for Google Code Project Hosting".code.google.com.
  14. ^Weizenbaum, Natalie (2021-11-01)."Officially mark this repository as end-of-life". Retrieved2023-07-18.

External links

[edit]
Google free and open-source software
Software
Applications
Programming languages
Frameworks and
development tools
Operating systems
Related
Code analysis
Subsets,* supersets
Transpilers
Concepts
Debuggers
Documentation generators
Editors (comparison)
Engines
Frameworks
Relatedtechnologies
Package managers
Module bundlers
Server-side
Unit testing frameworks (list)
People
Retrieved from "https://en.wikipedia.org/w/index.php?title=Google_Closure_Tools&oldid=1319055761"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp