News for hackers. Stuff that matters.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by tedmiston on Saturday September 17, 2016 @11:24AM (#12520856)
> This simply should be a build step

This is a great point, but when I think of build steps, I think of something like minifying which comes with a performance gain.

I'm not sure I see what the obvious gain to omitting optional tags in the way Google suggests is.

Edit: To clarify, I'm wondering if there's some performance gain by the browser not having to parse the implicit optional tags.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by jacobevelyn on Saturday September 17, 2016 @11:47AM (#12520965)
How is a build step that turns your HTML into a smaller amount of HTML with the exact same behavior (by removing optional tags) different from a "minification" step that turns your HTML or JS into a smaller amount of HTML/JS with the exact same behavior?

This is minification, isn't it?

Re:Google HTML/CSS Style Guide – Omit Optional Tags by tedmiston on Saturday September 17, 2016 @11:52AM (#12520991)
Updated to clarify my comment as a reference to browser performance not file size.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by the_duke on Saturday September 17, 2016 @01:17PM (#12521360)
Smaller file size -> faster loading (in theory... if gzipped, it's probably redundant).

Possibly faster parsing, because the parser has less HTML so go through. (also probably not valid, because I'd be pretty sure that reading a string from memory is not the bottleneck in parsing, compared to logic, memory allocations, etc).

It could make a difference for Googles server infrastructure though.

If they have to download a tiny bit less, and save a tiny bit on CPU cycles and memory for each page, , it might still lead to considerably savings.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by nevir on Saturday September 17, 2016 @12:07PM (#12521049)
> I'm wondering if there's some performance gain by the browser not having to parse the implicit optional tags.

The motivation behind this style is not browser parsing perf - it's network perf. The smaller your HTTP response, the fewer packets (and round trips) required to transmit it.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by DougWebb on Saturday September 17, 2016 @12:33PM (#12521166)
If your output is compressed (which it should be if you're worried about response size) then omitting end tags has much less impact, I believe. All of the tags should get compressed well because they're repeated so often, and they should be much smaller overall than your non-repetitive content.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by TheRealPomax on Saturday September 17, 2016 @01:25PM (#12521410)
But note that on the scale of move as much data around as Google does, or even "the web as a whole", shaving even a few bytes off of every single gzip packet stream can still equate to significant network relief.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by DougWebb on Saturday September 17, 2016 @01:56PM (#12521565)
I suspect their advice is for their benefit, not other website devs. They can save a lot of space in their archive if everyone's pages were smaller. Nothing compared to better image compression though.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by dgacmu on Saturday September 17, 2016 @02:43PM (#12521789)
No - a few bytes on a web page are insignificant compared to the data volume of images and movies. This is all about getting pages to load faster on mobile.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by nevir on Tuesday September 20, 2016 @05:44PM (#12543679)
If those extra bytes drop you from two packets to one, that's a _significant_ reduction in traffic

(which, IIRC, was the original rationale behind that style guide rule)

Re:Google HTML/CSS Style Guide – Omit Optional Tags by h1d on Saturday September 17, 2016 @12:31PM (#12521159)
If you would gzip your output like you should, how much does that even buy? There's usually something better to use your time for instead of trying to shave 500 bytes out of your page.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by TheRealPomax on Saturday September 17, 2016 @12:43PM (#12521204)
it's not a competition, though. If there's something better to do, also do that. However, that does still leave the question of how many bytes are actually saved in transport, especially with gzipping. The benefit here is absolutely not individual developers or even individual sites, but the data transfered by entire data centers over the course of a day, week, month etc. If this recommendation can bring down the total byte transmission for "the web" by 0.001% for instance, that's still a boatload of bytes that don't bog down the network anymore.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by Dylan16807 on Saturday September 17, 2016 @03:22PM (#12521977)
When you're looking at fractions of a percent, remember to consider other options. Set up brotli, for example. Or redesign your site to have a leaner layout. You might not ever reach the efficiency level where optimizing optional tags is the best use of dev time.

And the overhead of tracking which tags are optional in which circumstances is not particularly small. Consider that the extra complexity could impede more optimizations in the future, especially now that your markup requires a more complex parser than it could have needed.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by the_duke on Saturday September 17, 2016 @01:25PM (#12521409)
Have you looked at the size of Youtube and Netflix videos?

According to this study [1], 70% of web traffic is video streaming. Only 8% are web browsing (which might include images, because they are not mentioned anywhere else - didn't find any info on that).

This is not going to make any difference.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by TheRealPomax on Saturday September 17, 2016 @01:31PM (#12521438)
Just because the vast majority of roads are for cars doesn't mean we should therefore not try to optimize the bike and pedestrian lanes.

Sure, a lot of the traffic is streamed data rather than HTML, but 30% of close to a zetabyte of data in a single day (for the internet as a whole) is still hundreds of petabytes that can be made drastically smaller. When the numbers are that large, even optimizing for something as "insignificant" as 0.01% of the traffic means 10s or even 100s of terabytes not pumped through the network every day.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by h1d on Saturday September 17, 2016 @01:42PM (#12521502)
You sound like you want to act for the good of the whole human beings but we have priorities over shaving the last bytes off our pages.

You would have a better day to let webmasters know to use gzip if they aren't.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by TheRealPomax on Saturday September 17, 2016 @04:46PM (#12522363)
As always: optimizations are not a matter a of "one or the other" they're about "do all of them". Make the build tool apply all optimizations and minifications, and make the client-server connection negotiate as much compression as possible. Don't stop at just gzip when further improvements are trivial (like this one).
Re:Google HTML/CSS Style Guide – Omit Optional Tags by M2Ys4U on Sunday September 18, 2016 @09:43AM (#12525263)
compression and encryption often don't play nice with each other. See CRIME and BREACH, for example.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by bcoates on Saturday September 17, 2016 @12:30PM (#12521152)
The double negative phrasing Google and the spec uses makes it sound weirder than it is. You could phrase it as "only use tags that are needed for the document to be parsed correctly" which makes explicitly including an <html> tag with no attributes or a information-free stack of closing tags seem like a strange thing to do if it wasn't tradition.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by rtpg on Saturday September 17, 2016 @11:29AM (#12520882)
file size? It's not much, but it would still strip some stuff.

I'm still bitter that HTML/XML works based off of explicit closing tags (where you can mistakenly close the wrong tag) instead of something like braces.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by TheRealPomax on Saturday September 17, 2016 @01:33PM (#12521454)
Use a build tool (which you should be doing anyway if you hand-write any markup, because you need to validate it) and make it rewrite </> to the relevant closing tag, if necessary... problem solved? (and yes, you'd be free to even leave </> off in many, many places: https://www.w3.org/TR/html5/syntax.html#optional-tags).

Alternatively, don't use HTML at all. Use pug (formerly "jade") or something and now you're free from all those inconvenient angle brackets.

Re:Google HTML/CSS Style Guide – Omit Optional Tags by lgamero on Saturday September 17, 2016 @03:14PM (#12521940)
After using pug, I don't think I can go back to plain HTML. I didn't know how much i hated closing tags.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by a3n on Saturday September 17, 2016 @11:35AM (#12520919)
Maybe it reduces the load on Google's crawls of the web.
Re:Google HTML/CSS Style Guide – Omit Optional Tags by sotojuan on Saturday September 17, 2016 @11:28AM (#12520874)
Less HTML to load? Probably makes no difference in most cases, but it is less to load.

Many React/Webpack flows do something like this (minify or use a barebones template HTML).

Re:Google HTML/CSS Style Guide – Omit Optional Tags by bpicolo on Saturday September 17, 2016 @11:32AM (#12520901)
Seems like something you can add a build step for though. Less human overhead
Re:Google HTML/CSS Style Guide – Omit Optional Tags by sotojuan on Saturday September 17, 2016 @01:05PM (#12521305)
Sorry I wasn't very clear, that's what I meant by "React/Webpack" flow! See: https://github.com/ampedandwired/html-webpack-plugin