"Omit head and body tags, & type attributes to reduce filesize..."
I'm pretty sure you could remove all the head and body tags from the entire internet and it would still make less of a performance impact than if every WordPress blog stopped using Google fonts.
A single analytics loading script and the tracking payload is larger than the gains from the removal of these tags. Most pages have more than one script and payload too.
I vaguely remember years ago google.com omitting tags to strip file size and there being some mild controversy around it. Pretty sure it was before HTML 5 adaption and don't think back then the tags where optional, just that browsers try to interpret whatever mess is thrown at them.
True, for source code it might be better to leave those in. However, the fact that omitting them is standard-compliant is interesting for automated minimizers.
I tried this for a summer, it really did lead to easier to read HTML... although now when I go back I’m not sure which tags can be omitted and which might be errors. I think it’s probably a net negative trade off but still not certain.
These days Im trying out pug instead, which is similar in a sense: more concise and readable at the expense of other people being certain of its correctness and myself remembering the syntax months later.
In my reading of this, I wouldn't say they "recommend" it, but that they recommend considering it. Their link is quite clear that HTML 5 makes these tags optional and gives an unambiguous mapping onto the traditional structure.
It's optional under certain conditions but those conditions are given as you correctly point out in the link to the HTML standard. While many seem to be focused on what Google says, it's nothing that those of us who read the actual spec didn't already know.
And every web developer references the spec when they have questions...don't they?
This seems like insane advice. Even if it's technically permitted, the HTML5 spec page they themselves link to shows a bunch of caveats and exceptions that make it risky.
Omitting tags is something we can get used to, but just by looking at the spec I'm kinda scratching my head.
Eg. why can't the closing tag for title be omitted? Tags are not allowed inside it.
I guess it's because you should be able to type tags as the title, but having to think about stuff like that makes ommiting more of a hassle than it's worth to me.
And what if templates are used and put together? Then you suddenly need to know how every combination of templates is going to be in the future to avoid unintended side effects.
Saving a bit of data on HTML isn't my top priority, and why would it? Just by not using a bunch of css/js-libs/fonts I'm able to have a smaller footprint than 99 percent of all pages.
They are implied. I believe this dates back to when browsers supported non-standard HTML and the behavior of doing it was cemented in HTML5 (like tag soup and so forth.) Since it was based on existing behavior it should work even in old IE, just like the doctype.
I disagree, having these tags give the document a structure that makes it easier for machines to understand. As for indenting, I usually break the consistency and put html, head and body at column 1, starting the indenting for anything inside head and body.
It's funny that the company that tries to "accelerate" web pages by directing webmasters to build their websites using a 270k AMP script internally guides its developers to size optimize by omitting the spoonfuls of bytes for optional tags—in a document that in itself doesn't follow these guidelines and is possibly the simplest page that Google has ever produced. What an absurd state of affairs.
To be clear, for anyone confused about the "main HTML tag" in the title, this recommendation is essentially to eliminate <html><head></head><body></body></html>.
> This project (google/styleguide) links to the style guidelines we use for Google code. If you are modifying a project that originated at Google, you may be pointed to this page to see the style guides that apply to that project.
These are just Google's style guides for their own code. They're not saying you should do this in your own code.
Is there much savings omitting body and head tags?
This seems like excessive optimization where having them there sometimes because someone left them in, but omitted the next because someone else removed them seems like it could be confusing, a few brain cycles might be more valuable than the possible savings.
Granted I'm not Google so maybe there are some great savings to be had there, I'd like to know what they are.
> This approach may require a grace period to be established as a wider guideline as it’s significantly different from what web developers are typically taught.
Interesting... I have never done this except on small test/toy projects at home. I think the main downside today is probably just that the structure of the document is sort of implied, and it may be unclear to new developers why its possible to style html/body when they don’t exist. It does work consistently across browsers last I checked, though.
I was mystified the first time I read about "byte order mark" and I'm still confused. I mean, I know that if you want to waste space on 16-bit characters, it might make some very small amount of sense to have a byte-order mark, but for crying out loud, just standardize that order and live with it. We don't need more parts of text file that are interpretable, and cause both usability problems and security problems.
Aren't there lots of scripts that depend on the head, body, and even html tags? The HTML tag in particular is used for a lot of feature detection, and the body is used as the root element for a lot of SPAs.
That's not to say that abolishing those tags isn't a great idea, but it would be harder than it looks for projects with an appreciable number of dependencies. I'm definitely in support of never writing that stupid <html> tag again.
[+] [-] zelon88|6 years ago|reply
I'm pretty sure you could remove all the head and body tags from the entire internet and it would still make less of a performance impact than if every WordPress blog stopped using Google fonts.
[+] [-] wybiral|6 years ago|reply
[+] [-] kllrnohj|6 years ago|reply
But there's no reason to ignore literally free improvements just because there's bigger, not free improvements to be had as well.
[+] [-] jimktrains2|6 years ago|reply
[+] [-] gorzynsk|6 years ago|reply
[+] [-] yeahitslikethat|6 years ago|reply
[+] [-] hkai|6 years ago|reply
[+] [-] myl|6 years ago|reply
[+] [-] spankalee|6 years ago|reply
[+] [-] smoe|6 years ago|reply
[+] [-] yeahitslikethat|6 years ago|reply
[+] [-] bshimmin|6 years ago|reply
(Seems like a terrible idea to me - complex rules to follow for a really minimal saving...)
[+] [-] blauditore|6 years ago|reply
[+] [-] 52-6F-62|6 years ago|reply
[+] [-] jammygit|6 years ago|reply
These days Im trying out pug instead, which is similar in a sense: more concise and readable at the expense of other people being certain of its correctness and myself remembering the syntax months later.
[+] [-] sarah180|6 years ago|reply
[+] [-] sureaboutthis|6 years ago|reply
And every web developer references the spec when they have questions...don't they?
[+] [-] apetresc|6 years ago|reply
And for what - to save literally 10 bytes?
[+] [-] falsedan|6 years ago|reply
[+] [-] NightlyDev|6 years ago|reply
Eg. why can't the closing tag for title be omitted? Tags are not allowed inside it.
I guess it's because you should be able to type tags as the title, but having to think about stuff like that makes ommiting more of a hassle than it's worth to me.
And what if templates are used and put together? Then you suddenly need to know how every combination of templates is going to be in the future to avoid unintended side effects.
Saving a bit of data on HTML isn't my top priority, and why would it? Just by not using a bunch of css/js-libs/fonts I'm able to have a smaller footprint than 99 percent of all pages.
[+] [-] saurik|6 years ago|reply
[+] [-] pdw|6 years ago|reply
The example document in the HTML+ spec (1993) did not use them: https://www.w3.org/MarkUp/HTMLPlus/htmlplus_7.html
The HTML 2.0 spec gives this as its first example:
[+] [-] ntzm|6 years ago|reply
[+] [-] jchw|6 years ago|reply
[+] [-] Tomte|6 years ago|reply
[+] [-] yoz-y|6 years ago|reply
Note though that there are some conditions.
[+] [-] jacobsenscott|6 years ago|reply
[+] [-] netsharc|6 years ago|reply
[+] [-] pupppet|6 years ago|reply
[+] [-] boomlinde|6 years ago|reply
[+] [-] wycy|6 years ago|reply
[+] [-] satori99|6 years ago|reply
I thought it was referring to the <main> tag.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ma...
[+] [-] Camillo|6 years ago|reply
> This project (google/styleguide) links to the style guidelines we use for Google code. If you are modifying a project that originated at Google, you may be pointed to this page to see the style guides that apply to that project.
These are just Google's style guides for their own code. They're not saying you should do this in your own code.
[+] [-] boomlinde|6 years ago|reply
[+] [-] duxup|6 years ago|reply
Is there much savings omitting body and head tags?
This seems like excessive optimization where having them there sometimes because someone left them in, but omitted the next because someone else removed them seems like it could be confusing, a few brain cycles might be more valuable than the possible savings.
Granted I'm not Google so maybe there are some great savings to be had there, I'd like to know what they are.
[+] [-] ianhawes|6 years ago|reply
[+] [-] dragonwriter|6 years ago|reply
[+] [-] jchw|6 years ago|reply
[+] [-] pingucrimson|6 years ago|reply
[+] [-] dragonwriter|6 years ago|reply
[+] [-] JoshMnem|6 years ago|reply
Is it correct to put a title element outside of a head element?
"Permitted parents: A <head> element that contains no other <title> element."
"The <title> element is always used within a page's <head> block."
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ti...
Google's style guides aren't very good in general, including Python, which doesn't follow PEP8.
[+] [-] edflsafoiewq|6 years ago|reply
[+] [-] bediger4000|6 years ago|reply
> Use UTF-8 (no BOM).
I was mystified the first time I read about "byte order mark" and I'm still confused. I mean, I know that if you want to waste space on 16-bit characters, it might make some very small amount of sense to have a byte-order mark, but for crying out loud, just standardize that order and live with it. We don't need more parts of text file that are interpretable, and cause both usability problems and security problems.
[+] [-] ravenstine|6 years ago|reply
That's not to say that abolishing those tags isn't a great idea, but it would be harder than it looks for projects with an appreciable number of dependencies. I'm definitely in support of never writing that stupid <html> tag again.
[+] [-] alexhutcheson|6 years ago|reply
[+] [-] edflsafoiewq|6 years ago|reply
[+] [-] yodon|6 years ago|reply