by tedmiston · 10y ago · 0 comments
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.
This is minification, isn't it?
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.
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.
(which, IIRC, was the original rationale behind that style guide rule)
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.
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.
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.
Alternatively, don't use HTML at all. Use pug (formerly "jade") or something and now you're free from all those inconvenient angle brackets.
Many React/Webpack flows do something like this (minify or use a barebones template HTML).