46. ! Failed rule "validate-attributes".
" The 'bgcolor' attribute is no longer valid on the <body>
element and should not be used.
HTMLは文書構造を定義、CSSは装飾やレイアウト
という切り分けを行いましょう。
47. ! Failed rule "unused-classes".
" The class 'hoge' is used in the HTML but not found in any
stylesheet.
定義されていないCSSはHTMLで参照しないように
しましょう。CSSの参照コストが発生してしまい
ます。
48. ! Failed rule "unnecessary-elements".
" Do not use <div> or <span> elements without any
attributes.
CSSの装飾や、属性値も持たない<div>や<span>
は必要ないはずです。深ければ深いほど、描画時
のリフローの回数が増え、CSSやJSの参照のコス
トが増えます。
49. ! Failed rule "validate-attributes".
" The 'alt' attribute is required for <img> elements.
必須とされている属性値は記述するようにしま
しょう。ちなみに、<img>にはwidthとheightを
つけるのが望ましいです。そして、srcの値を空に
しないようにしましょう。
51. ! Failed rule "validate-elements".
" The <font> element is obsolete and should not be used.
<font>タグは非推奨です。前述の通り、HTMLは
文書構造の定義という役割になったためです。
<center>、<basefont>、<u>、<s>等にも同様の
ことが言えます。
53. ! Failed rule "inline-event-handlers".
" An 'onclick' attribute was found in the HTML. Use
external scripts for event binding instead.
イベントの定義はJSファイルで行うようにしま
しょう。インラインの定義は管理が非常に難しく、
予期しない不具合を引き起こします。
55. ! Failed rule "script-placement".
" <script> elements should appear right before the closing
</body> tag for optimal performance.
<script>タグは同期的に実行されるため、その間
ページの描画が止まります。</body>の上に置く
ことでそれを極力避ける事ができます。
57. Values of 0 shouldn't have units specified. You don't need
to specify units when a value is 0. (zero-units)
0pxも0%も0であることに変わりはありません。
単位を削ってファイルサイズを減らしましょう。
58. Element (a.active) is overqualified, just use .active
without element name. Don't use classes or IDs with elements
(a.foo or a#foo). (overqualified-elements)
a.activeは不要に詳細度が増しているセレクタで
す。.activeとし、タグに依存しないようにしま
しょう。セレクタにIDを使用するのもやめましょ
う。
60. The properties padding-top, padding-bottom, padding-left,
padding-right can be replaced by padding. Use shorthand
properties where possible. (shorthand)
ショートハンドで記述し、冗長な表現は避けましょ
う。
67. Use '!==' to compare with 'null'
nullとの比較に限らず、基本的に厳密等価演算子
を推奨します。キャストがない分高速である上、
暗黙の型変換は誤解を招きやすいです。
68. Equals Operator vs Strict Operator
http://jsperf.com/equals-operator-vs-strict-equals-
operator/2
69. The object literal notation {} is preferrable.
The array literal notation [] is preferrable.
new Array()による配列の初期化は、引数がわかり
にくいです。双方ともリテラルを使ったほうが完
結でわかりやすいです。
70. var array1 = new Array("foo"); // ["foo"]
!
var array2 = new Array("foo", "bar"); // ["foo", "bar"]
!
var array3 = new Array(3); // [] and array3.length is 3
var array1 = ["foo"]; // ["foo"]
!
var array2 = ["foo", "bar"]; // ["foo", "bar"]
!
var array3 = [undefined, undefined, undefined];
// [] and array3.length is 3
「Objectはもっとわかりにくいので割愛…。」