> Citation needed re: "way more efficient". While that might seem intuitively true, it is not clear to me that it must be so in practice.
True, I'm not sure what the actual number would look like, but imagine these two pseudo code snippets:
```js
let tag = '';
for (let char = stream.readChar(); char != WHITESPACE; char = stream.readChar()) {
tag += char;
}
// parse props
// ...
document.createElement(tag)
```
```js
let tag = '';
let isCustomTag = stream.readBool();
if (!isCustomTag) { // easily more than 95% hit rate (humble guess)
tag = standardHTMLTags[stream.readUint32()];
} else {
// similar for loop as earlier
}
```
Optimisations along these lines but in tens of more situations like this, for both HTML and CSS. Also, a lot nuances, like how every text file is a valid html file and the parser just has to figure out the best structure while never throwing en error, would not need to be handled, or be handled in a website's build process.
I'd have to write an actual implementation for proper numbers though, maybe over some weekend if after this discussion it actually seems like a optimisation worth the effort of implementation/adoption.
> I doubt however that for a modern RAM/CPU having to compare 128 or 256 bits which is roughly the length of most tokens makes much difference to comparing 32 bits.
Comparing more bits isn't the issue, the issue is those strings of bits being of variable length. If every HTML tag was 256 bits, going from 256 to 32 wouldn't have made much difference, but having to find the end of a string has a lot of overhead.
> All the rest of dealing with HTML/CSS like layout computation, event handling is going to eat most of the time and the benefit of small tokens will be dwarfed completely while the downside of lost readability of the raw data will be real.
Yea tbh that could be the case. There won't be any loss of readability other than custom indentation details and comments, but the performance improvement would probably only be around 1-2% of the loading time. I just ran a quick profiler on this page for first 2 seconds of loading and parsing HTML took 71.9ms. I'm guessing it could go down to, let's say, around 20ms. That's more or less all what it would do.