From f43f7a72b5a97a8aa256ef0d0d377590846575df Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 25 Sep 2026 16:31:56 -0400 Subject: [PATCH] javascriptguide: turn down old ES5 guide We kept this around for posterity, but all things die eventually. ES6 was released over a decade ago and there's really no reason to write new code targeting ES5 or older. If you actually need to target such a system, transpilers like Babel are the way to go. Removing this guide allows us to remove the styleguide.css file as no other guide relies on it. --- 404.html | 3 +- javascriptguide.html | 3691 ------------------------------------------ styleguide.css | 164 -- 3 files changed, 2 insertions(+), 3856 deletions(-) delete mode 100644 javascriptguide.html delete mode 100644 styleguide.css diff --git a/404.html b/404.html index 8d60c79..014bfe0 100644 --- a/404.html +++ b/404.html @@ -15,7 +15,8 @@ window.onload = function() { 'cppguide.xml': 'cppguide.html', 'google-r-style.html': 'Rguide.html', 'htmlcssguide.xml': 'htmlcssguide.html', - 'javascriptguide.xml': 'javascriptguide.html', + 'javascriptguide.xml': 'jsguide.html', + 'javascriptguide.html': 'jsguide.html', 'jsoncstyleguide.html': 'jsoncguide.html', 'jsoncstyleguide.xml': 'jsoncguide.html', 'lispguide.xml': 'lispguide.html', diff --git a/javascriptguide.html b/javascriptguide.html deleted file mode 100644 index c93a9d0..0000000 --- a/javascriptguide.html +++ /dev/null @@ -1,3691 +0,0 @@ - - -Google JavaScript Style Guide - - - - - - -

Google JavaScript Style Guide

-

- Please note: This guide is old and is not being updated. It is retained - as a reference as it was written for pre-ECMAScript 6th Edition features. - Please use the newer guide instead. -

-

- Revision 2.93 -

- -
- Aaron Whyte
- Bob Jervis
- Dan Pupius
- Erik Arvidsson
- Fritz Schneider
- Robby Walker
-
-
-

- Each style point has a summary for which additional information is available - by toggling the accompanying arrow button that looks this way: - ▶. - You may toggle all summaries with the big arrow button: -

-
-▶ - Toggle all summaries -
-
-
-
Table of Contents
- - - - - - - - - -
-
-
-

Important Note

-
-

Displaying Hidden Details in this Guide

- - link - ▶ -
- This style guide contains many details that are initially - hidden from view. They are marked by the triangle icon, which you - see here on your left. Click it now. - You should see "Hooray" appear below. -
-
-
-
-
-

Background

-

- JavaScript is the main client-side scripting language used - - by many of Google's open-source - projects. - This style guide is a list of dos and don'ts for - JavaScript programs. -

- - - - - -
- -
-

JavaScript Language Rules

- - - - -
-

var

- - link - ▶ -
- Declarations with var: Always -
-
-
- -
-

Constants

- - link - ▶ -
-
    -
  • Use NAMES_LIKE_THIS for constant values.
  • -
  • Use @const to indicate a constant (non-overwritable) - pointer (a variable or property).
  • -
  • Never use the - - const keyword - as it's not supported in Internet Explorer.
  • -
-
-
-
- -
-

Semicolons

- - link - ▶ -
- Always use semicolons. -
-
-
- -
-

Nested functions

- - link - ▶ -
Yes
-
-
- -
-

Function Declarations Within Blocks

- - link - ▶ -
No
-
-
- -
-

Exceptions

- - link - ▶ -
Yes
-
-
- -
-

Custom exceptions

- - link - ▶ -
Yes
-
-
- -
-

Standards features

- - link - ▶ -
Always preferred over non-standards features
-
-
- -
-

Wrapper objects for primitive types

- - link - ▶ -
No
-
-
- -
-

Multi-level prototype hierarchies

- - link - ▶ -
Not preferred
-
-
- -
-

Method and property definitions

- - link - ▶ -
/** @constructor */ - function SomeConstructor() { - this.someProperty = 1; - } - Foo.prototype.someMethod = function() { ... };
-
-
- -
-

delete

- - link - ▶ -
Prefer this.foo = null.
-
-
- -
-

Closures

- - link - ▶ -
Yes, but be careful.
-
-
- -
-

eval()

- - link - ▶ -
- Only for code loaders and REPL (Read–eval–print loop) -
-
-
- -
-

with() {}

- - link - ▶ -
No
-
-
- -
-

this

- - link - ▶ -
- Only in object constructors, methods, and in setting up closures -
-
-
- -
-

for-in loop

- - link - ▶ -
- Only for iterating over keys in an object/map/hash -
-
-
- -
-

Associative Arrays

- - link - ▶ -
- Never use Array as a map/hash/associative array -
-
-
- -
-

Multiline string literals

- - link - ▶ -
No
-
-
- -
-

Array and Object literals

- - link - ▶ -
Yes
-
-
- -
-

Modifying prototypes of builtin objects

- - link - ▶ -
No
-
-
- -
-

Internet Explorer's Conditional Comments

- - link - ▶ -
No
-
-
-
- -
-

JavaScript Style Rules

-
-

Naming

- - link - ▶ -
-

In general, use - functionNamesLikeThis, - variableNamesLikeThis, - ClassNamesLikeThis, - EnumNamesLikeThis, - methodNamesLikeThis, - CONSTANT_VALUES_LIKE_THIS, - foo.namespaceNamesLikeThis.bar, and - filenameslikethis.js. -

-
-
-
- -
-

Custom toString() methods

- - link - ▶ -
- Must always succeed without side effects. -
-
-
- -
-

Deferred initialization

- - link - ▶ -
OK
-
-
- -
-

Explicit scope

- - link - ▶ -
Always
-
-
- -
-

Code formatting

- - link - ▶ -
Expand for more information.
-
-
- -
-

Parentheses

- - link - ▶ -
Only where required
-
-
- -
-

Strings

- - link - ▶ -
Prefer ' over "
-
-
- -
-

Visibility (private and protected fields)

- - link - ▶ -
Encouraged, use JSDoc annotations @private and - @protected -
-
-
- -
-

JavaScript Types

- - link - ▶ -
Encouraged and enforced by the compiler.
-
-
- -
-

Comments

- - link - ▶ -
Use JSDoc
-
-
- -
-

Providing Dependencies With goog.provide

- - link - ▶ -
- Only provide top-level symbols. -
-
-
- -
-

Compiling

- - link - ▶ -
Required
-
-
- -
-

Tips and Tricks

- - link - ▶ -
JavaScript tidbits
-
-
-
- - - -

Parting Words

-

- BE CONSISTENT. -

- -

- If you're editing code, take a few minutes to look at the code - around you and determine its style. If they use spaces around - all their arithmetic operators, you should too. If their - comments have little boxes of hash marks around them, make your - comments have little boxes of hash marks around them too. -

- -

- The point of having style guidelines is to have a common vocabulary - of coding so people can concentrate on what you're saying rather - than on how you're saying it. We present global style rules here so - people know the vocabulary, but local style is also important. If - code you add to a file looks drastically different from the existing - code around it, it throws readers out of their rhythm when they go to - read it. Avoid this. -

- - - -

- Revision 2.93 -

- - -
- Aaron Whyte
- Bob Jervis
- Dan Pupius
- Erik Arvidsson
- Fritz Schneider
- Robby Walker
-
- - diff --git a/styleguide.css b/styleguide.css deleted file mode 100644 index 6c044c3..0000000 --- a/styleguide.css +++ /dev/null @@ -1,164 +0,0 @@ -body { - background-color: #fff; - color: #333; - font-family: sans-serif; - font-size: 10pt; - margin-right: 100px; - margin-left: 100px; -} - -h1, -h2, -h3, -h4, -h5, -h6, -.toc_title { - color: #06c; - margin-top: 2em; - margin-bottom: 1em; -} - -h1 { - text-align: center; - font-size: 18pt; -} - -h2, -.toc_title { - font-weight: bold; - font-size: 12pt; - margin-left: -40px; -} - -h3, -h4, -h5, -h6 { - font-size: 10pt; - margin-left: -20px; -} - -.toc_category, -.toc_stylepoint { - font-size: 10pt; - padding-top: 0.3em; - padding-bottom: 0.3em; -} - -table { - border-collapse: collapse; -} - -td, -th { - border: 1px solid #ccc; - padding: 2px 12px; - font-size: 10pt; -} - -.toc td, -.toc th { - border-width: 1px 5px; -} - -code, -samp, -var { - color: #060; -} - -pre { - position: relative; - font-size: 10pt; - display: block; - color: #060; - background-color: #f8fff8; - border: 1px solid #f0fff0; - border-left-width: 5px; - padding: 4px 12px; -} - -pre:before { - position: absolute; - top: 4px; - right: 4px; - z-index: 1; - content: "GOOD CODE"; -} - -pre.badcode { - color: #c00; - background-color: #fff8f8; - border-color: #fff0f0; -} - -pre.badcode:before { - content: "BAD CODE"; -} - -.showhide_button { - float: left; - cursor: pointer; - border: 1px solid; - border-color: #ddd #aaa #aaa #ddd; - padding: 0 3px 1px; - margin: 0 4px 8px 0; - border-radius: 3px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; -} - -.link_button { - float: left; - display: none; - background-color: #f8f8ff; - border: 1px solid #f0f0ff; - font-size: 75%; - margin-top: 0; - margin-left: -50px; - padding: 4px; - border-radius: 3px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; -} - -address { - text-align: right; -} - -hr { - margin-top: 3.5em; - border-width: 1px; - color: #fff; -} - -.stylepoint_section { - display: block; - margin-bottom: 1em; - color: #58f; - font-family: sans-serif; - font-size: 90%; - font-weight: bold; - margin-left: -2%; -} - -.stylepoint_subsection { - color: #679; - font-family: sans-serif; - font-size: 90%; - font-weight: bold; - margin-left: -1%; -} - -.stylepoint_subsubsection { - color: #679; - font-family: sans-serif; - font-size: 80%; - font-weight: bold; - margin-left: 0; -} - -.revision { - text-align: right; -}