ちょいと考察するタイミングがあったもんで、考察したり調べたり。
おいちゃんの基本方針は
・デザイナさんが書いてくるHTMLは「それが正義」
・おいちゃんが(主にmockupで)書く時は
→ liとかテーブル(tr th td)とかリスト(dl dt)とかは省略
くらいの感じでざっくりと書いてます。
んで、色々あってちょいと調べてたら面白いものにぶち当たったので、ちょいと書いておこうかなぁ、と。
Google HTML/CSS Style Guide
https://google.github.io/styleguide/htmlcssguide.html
ってのがあって(初めて知ったけど「まぁあるよねぇ」くらいで、驚きは無し)。
https://google.github.io/styleguide/htmlcssguide.html#Indentation
Indent by 2 spaces at a time.
へぇ「2スペなんだ」。
https://google.github.io/styleguide/htmlcssguide.html#Document_Type
Use HTML5.
うんわかる。
https://google.github.io/styleguide/htmlcssguide.html#HTML_Validity
Use valid HTML where possible.
そらそうだろうよ。
で読んでいくと……
https://google.github.io/styleguide/htmlcssguide.html#Optional_Tags
Omit optional tags (optional).
For file size optimization and scannability purposes, consider omitting optional tags. The HTML5 specification defines what tags can be omitted.
………を?
うん、例が載ってる。
<!-- Not recommended --> <!DOCTYPE html> <html> <head> <title>Spending money, spending bytes</title> </head> <body> <p>Sic.</p> </body> </html>
<!-- Recommended --> <!DOCTYPE html> <title>Saving money, saving bytes</title> <p>Qed.
……まぢ???
いやまぁ「雑に書く」時とか、headとbodyとか省略しているし「省略できるのは知ってる」けど、これが「推奨」なの???
「For file size optimization and scannability purposes, consider omitting optional tags.」って言われると反論がしにくいのですが(笑
いやまぁわからんでもないのですが、「削れるものは削れ」というあたりは、うん、まぁ、ピーキーで嫌いじゃないよwww
なんか過去にごくうっすら「終了タグ省略するとレンダリング(っつかその手前のパース)で時間がかかる」とかって話を聞いたような記憶がうっすらあるんだけど、どこぞの検証だと「終了タグ、削ったほうがレンダリングが早い」なんて検証もあったので。
まぁとはいえ「言うほど通信量もレンダリング速度も影響あるんかね?」とか思うので割合に「どっちでもいいんぢゃね?」くらいの感じではあるのですが。
ググるさんの規約がなんか微妙にツボったので、メモ(笑